Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » FileSystemImportWizard and the .metadata directory
FileSystemImportWizard and the .metadata directory [message #326656] Thu, 27 March 2008 16:09 Go to next message
Eclipse UserFriend
Originally posted by: pawiusz.gmail.com

Hi!

I would like to add the FileSystemImportWizard to my application. I would
like to init this in such way, that it should point out to my
plugin's .metadata directory. Is it possible?

According to the documention about FileSystemImportWizard, this class should
be invoked as follows:

IWizard wizard = new FileSystemImportWizard();
wizard.init(workbench, selection);
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();

The 'selection' attribute should point out to the .metadata directory:

final IWorkspaceRoot myWorkspaceRoot =
ResourcesPlugin.getWorkspace().getRoot();

final IPath metadataPath =
MyPluginActivator.getDefault().getStateLocation();

StructuredSelection selection = new
StructuredSelection(myWorkspaceRoot.getFolder(metadataPath)) ;

The problem is, that this is not working. I have investigated the source
code of the FileSystemImportWizard class and it works as follows:

Object firstElement = selection.getFirstElement();

IResource res = null;
if (firstElement instanceof IAdaptable) {
Object resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
if(resource != null) {
res = (IResource) resource;
}
}

Unfortunately, res.isAccessible() == false

How to get IResource instance of the .metadata directory, which is
accessible?

Best regards, Pawel.
Re: FileSystemImportWizard and the .metadata directory [message #326657 is a reply to message #326656] Thu, 27 March 2008 16:29 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
Could you explain what you are trying to accomplish by accessing the
..metedata directory? .metadata is not a resource, which is your problem.

Pawel Cieslak wrote:
> Hi!
>
> I would like to add the FileSystemImportWizard to my application. I would
> like to init this in such way, that it should point out to my
> plugin's .metadata directory. Is it possible?
>
> According to the documention about FileSystemImportWizard, this class should
> be invoked as follows:
>
> IWizard wizard = new FileSystemImportWizard();
> wizard.init(workbench, selection);
> WizardDialog dialog = new WizardDialog(shell, wizard);
> dialog.open();
>
> The 'selection' attribute should point out to the .metadata directory:
>
> final IWorkspaceRoot myWorkspaceRoot =
> ResourcesPlugin.getWorkspace().getRoot();
>
> final IPath metadataPath =
> MyPluginActivator.getDefault().getStateLocation();
>
> StructuredSelection selection = new
> StructuredSelection(myWorkspaceRoot.getFolder(metadataPath)) ;
>
> The problem is, that this is not working. I have investigated the source
> code of the FileSystemImportWizard class and it works as follows:
>
> Object firstElement = selection.getFirstElement();
>
> IResource res = null;
> if (firstElement instanceof IAdaptable) {
> Object resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
> if(resource != null) {
> res = (IResource) resource;
> }
> }
>
> Unfortunately, res.isAccessible() == false
>
> How to get IResource instance of the .metadata directory, which is
> accessible?
>
> Best regards, Pawel.


Re: FileSystemImportWizard and the .metadata directory [message #326664 is a reply to message #326657] Thu, 27 March 2008 19:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pawiusz.gmail.com

Francis Upton wrote:

> Could you explain what you are trying to accomplish by accessing the
> .metedata directory? .metadata is not a resource, which is your problem.
>

So this is not possible, isn't it?

I would like to provide to users some files immediately after installing my
plugin (without creating any projects in a workspace). These files have to
be available for other plugins (which means, they have to be accessable via
IFile interface). Therefore I store them in the .metadata directory.
Parhaps this is not the best solution. (I will be glad to hear other one).
However, it is probably too late to change my architecture.

best regards, Pawel.
Re: FileSystemImportWizard and the .metadata directory [message #326669 is a reply to message #326664] Thu, 27 March 2008 21:25 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
If you want to use resources (that is any subclass of IResource), then
you must store the resources in projects. You can't access anything
inside the .metadata directory because that's not part of what's
possible with resources.

You would have to create some kind of project to hold these files. Note
that with EFS and/or linking eclipse allows you to have the backing
store of the projects anywhere you want (like in a zip file, or the
plugin itself).

If these files don't change, you might consider just accessing them
directly from the JAR file of your plugin, by using the Java resource
mechanism (unrelated to the eclipse resource mechanism).

Hopefully this helps a little.

Francis

Pawel Cieslak wrote:
> Francis Upton wrote:
>
>> Could you explain what you are trying to accomplish by accessing the
>> .metedata directory? .metadata is not a resource, which is your problem.
>>
>
> So this is not possible, isn't it?
>
> I would like to provide to users some files immediately after installing my
> plugin (without creating any projects in a workspace). These files have to
> be available for other plugins (which means, they have to be accessable via
> IFile interface). Therefore I store them in the .metadata directory.
> Parhaps this is not the best solution. (I will be glad to hear other one).
> However, it is probably too late to change my architecture.
>
> best regards, Pawel.
>


Re: FileSystemImportWizard and the .metadata directory [message #326680 is a reply to message #326669] Fri, 28 March 2008 12:02 Go to previous message
Eclipse UserFriend
Originally posted by: pawiusz.gmail.com

Francis Upton wrote:

> If you want to use resources (that is any subclass of IResource), then
> you must store the resources in projects. You can't access anything
> inside the .metadata directory because that's not part of what's
> possible with resources.
>
> You would have to create some kind of project to hold these files. Note
> that with EFS and/or linking eclipse allows you to have the backing
> store of the projects anywhere you want (like in a zip file, or the
> plugin itself).
>
> If these files don't change, you might consider just accessing them
> directly from the JAR file of your plugin, by using the Java resource
> mechanism (unrelated to the eclipse resource mechanism).
>
> Hopefully this helps a little.

This helped me a lot, thank you! Pawel.
Previous Topic:Track dirty state of editor
Next Topic:Implementing A custom content compare/merge viewer
Goto Forum:
  


Current Time: Sun Jun 30 14:25:50 GMT 2024

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

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

Back to the top