Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Convention for persisting data in workspace other than project(How can I persist view data in something other than a project?)
Convention for persisting data in workspace other than project [message #1834684] Sun, 15 November 2020 21:04 Go to next message
Steve Vestal is currently offline Steve VestalFriend
Messages: 37
Registered: March 2013
Member
I am creating a view for a plugin that manages data I want to persist in the workspace. I don't want this in a project, as my view should be used to manage the data. This is somewhat analogous to preferences, or maybe how eGit views are used to manage data about repos. Is there a convention for persisting a set of files (such as a set of xml files) that are not visible in user-editable projects but are persisted in the workspace?
Re: Convention for persisting data in workspace other than project [message #1834701 is a reply to message #1834684] Mon, 16 November 2020 13:26 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

That's exactly what org.eclipse.core.runtime.Plugin#getStateLocation() is for, callable on the instance of the class you designated as your Bundle-Activator in the plug-in manifest.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Convention for persisting data in workspace other than project [message #1834728 is a reply to message #1834701] Tue, 17 November 2020 00:17 Go to previous messageGo to next message
Steve Vestal is currently offline Steve VestalFriend
Messages: 37
Registered: March 2013
Member
This starts out working, but I run into problems. When I execute

IPath pluginStatePath = getStateLocation();

It creates a folder in ..../.metadata/.plugins/my.plugin.id, as the javadoc says it will.

But then I do

IFolder pluginFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(pluginStatePath);
IResource[] files = pluginFolder.members();

and I get an exception on the call to members() that resource .../.metadata/.plugins/my.plugin.id does not exist, even thought I can see it in the workspace. pluginFolder.toString() does show the proper path to .../my.plugin.id, except that it has an F/ at the very beginning.

How do I iterate over the files contained in that folder?
Re: Convention for persisting data in workspace other than project [message #1834731 is a reply to message #1834728] Tue, 17 November 2020 04:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
The stuff in the .metadata folder is not visible as a workspace resource. You must access it using java.io or java.nio.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Convention for persisting data in workspace other than project [message #1834782 is a reply to message #1834731] Tue, 17 November 2020 19:25 Go to previous message
Steve Vestal is currently offline Steve VestalFriend
Messages: 37
Registered: March 2013
Member
Yep, File folderFile = pluginStatePath.toFile(); lets me do it.
Previous Topic:indent with spaces in "Generic Text Editor"
Next Topic:Open Workspace doesn't load project
Goto Forum:
  


Current Time: Thu Apr 25 23:41:17 GMT 2024

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

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

Back to the top