Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Properties for non IResource objects
Properties for non IResource objects [message #504129] Thu, 17 December 2009 11:43 Go to next message
Christian Rueck is currently offline Christian Rueck
Messages: 11
Registered: December 2009
Location: Germany
Junior Member
Hello,

I have extended the Project Explorer with the Common Navigator Framework so it displays my own resources within my own ProjectNature. These resources do not have a file system representation. They therefore do not implement IResource.

I would like to use these resources with properties now.

I haven't found a description how properties are saved. I assume that this is happening automatic. I suppose this will only work if the resources implement IResource (where else should Eclipse find a file system path and file name for the properties).

How can I make my resources implement (or adapt to) IResource? The JavaDoc says that a clients shall not implement IResource.

I would like to use the existing properties mechanism so other Plug-Ins can add properties to my resources.

Thanks a lot for every hint,

Christian
Re: Properties for non IResource objects [message #504153 is a reply to message #504129] Thu, 17 December 2009 13:43 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
This would be a good point to start with the properties view:
http://www.eclipse.org/articles/Article-Properties-View/prop erties-view.html


- Prakash
Platform UI Team, IBM

Blog <http://blog.eclipse-tips.com>
Twitter <http://www.twitter.com/Eclipse_Tips>
Re: Properties for non IResource objects [message #504160 is a reply to message #504129] Thu, 17 December 2009 14:11 Go to previous messageGo to next message
Christian Rueck is currently offline Christian Rueck
Messages: 11
Registered: December 2009
Location: Germany
Junior Member
Hello,

Thanks for the quick answer.
I have seen this article before and have already scanned through it. I think it doesn't explain how the properties are saved to the *.properties file, or is this to automatism but have to be individually programmed?

Best Regards,

Christian
Re: Properties for non IResource objects [message #504186 is a reply to message #504160] Thu, 17 December 2009 15:43 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IV
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
I think this is something that you have to do yourself. But I'm a little confused by what you mean by "properties" associated with resources.

Do mean the persistent properties? If so, there is no UI support for editing these.

Here are some good links for information on the CNF:

http://wiki.eclipse.org/index.php/Common_Navigator_Framework

Michael Elder's tutorials have a way to add a property editor for objects that have the .properties extension.

Let me know if you need more information.


Re: Properties for non IResource objects [message #504227 is a reply to message #504129] Thu, 17 December 2009 18:35 Go to previous messageGo to next message
Christian Rueck is currently offline Christian Rueck
Messages: 11
Registered: December 2009
Location: Germany
Junior Member
Hello,

Maybe I understood something wrong:

When I right click something (like a Java Project or Package) in the Project Explorer and select Properties, a Window opens where I can edit properties (for instance for a Java Package it says that it is an IFolder element that has Properties for the categories Run/Debug Settings, Resource, Subversion.

I think that several plugins (like the Subversion Plug-In) can add property categories and that these are stored somewhere in a persistent property file that is connected to the package. Therefore they are reloaded the next time I open Eclipse.

I want to use the same mechanism for my resources.

Best Regards,

Christian
Re: Properties for non IResource objects [message #504228 is a reply to message #504227] Thu, 17 December 2009 18:44 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IV
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
Ok, that's easy.

Use the org.eclipse.ui.propertyPages extension point.

And then specify your class which extends PropertiesPage.

You can specify the conditions when you want the properties page to appear, like this:

	<extension point="org.eclipse.ui.propertyPages">
	
  		<page
	        class="com.oaklandsw.transform.editor.TransformProjectPropertiesPage"
    	    id="com.oaklandsw.transform.filePropPage"
        	name="Data Integrator">
     		<enabledWhen>
        	<and>
           <instanceof
                 value="org.eclipse.core.resources.IProject">
           </instanceof>
           	<test
                 property="org.eclipse.core.resources.projectNature"
                 value="com.oaklandsw.transform.runtime.nature">
           </test>
        	</and>
     		</enabledWhen>
  		</page>	
  		<page class="com.oaklandsw.transform.editor.TransformFilePropertiesPage"
			id="com.oaklandsw.transform.projectPropPage" name="Data Integrator">
			<enabledWhen>
				<and>
         		<instanceof
           			value="org.eclipse.core.resources.IFile">
     			</instanceof>
					<test property="org.eclipse.core.resources.projectNature"
						value="com.oaklandsw.transform.runtime.nature" />
				</and>
			</enabledWhen>
		</page>
	</extension>


Re: Properties for non IResource objects [message #504339 is a reply to message #504129] Fri, 18 December 2009 07:19 Go to previous messageGo to next message
Christian Rueck is currently offline Christian Rueck
Messages: 11
Registered: December 2009
Location: Germany
Junior Member
Ok, this is how to get the property page installed in the UI framework. The initial question was how the properties entered there are saved as persistent properties to reappear in the next session. I see no other way to provide a filename for the resource than to implement the IResource interface. However the JavaDoc says that clients shall not implement it.

An off topic question: Is it normal, that I am not allowed to write more often than every 5 hours on this forum? If I do it tells me that I am spamming the forum, so I may not even be able to reply to messages in my topic.
Re: Properties for non IResource objects [message #504466 is a reply to message #504339] Sat, 19 December 2009 20:34 Go to previous message
Francis Upton IV is currently offline Francis Upton IV
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
It should allow you to post immediately as far as I know. You could send an email to the webmaster or file a bug against the Eclipse Foundation on this point.

Regarding keeping properties persistent. If you only have a small amount of properties, then you can use the persistent properties mechanism associated with the resource (see IResource.setPersistentProperties). It's really only designed for a small amount of information though (under 2K).

And another issue is that it's only stored with the resource while it's in the workspace. That is if you check in this file you need to make sure you store the properties in another form as this will not follow the file into source control. You also have to design your property sheet to update these.

I do use these for some things in my RCP application and I keep a parallel file in .settings at the project level that records the persistent properties for all of the resources in the project. That way this file can be checked in and out with the project so that the project can be moved across workspaces. This is work you have to so yourself though.


Previous Topic:Automatic updates of Launch Configuration
Next Topic:FC12 sqlite version error
Goto Forum:
  


Current Time: Sat Oct 25 19:13:06 GMT 2014

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

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