FileSystemImportWizard and the .metadata directory [message #326656] |
Thu, 27 March 2008 16:09 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Francis Upton IV![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=francisu%40ieee.org) 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.
Platform UI Committer for Common Navigator
http://wiki.eclipse.org/index.php/Common_Navigator_Framework
http://help.eclipse.org/galileo/topic/org.eclipse.platform.d oc.isv/guide/cnf.htm
|
|
|
Re: FileSystemImportWizard and the .metadata directory [message #326664 is a reply to message #326657] |
Thu, 27 March 2008 19:05 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Francis Upton IV![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=francisu%40ieee.org) 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.
>
Platform UI Committer for Common Navigator
http://wiki.eclipse.org/index.php/Common_Navigator_Framework
http://help.eclipse.org/galileo/topic/org.eclipse.platform.d oc.isv/guide/cnf.htm
|
|
|
Re: FileSystemImportWizard and the .metadata directory [message #326680 is a reply to message #326669] |
Fri, 28 March 2008 12:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.05146 seconds