Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [plugin ] problem with paths used in plugin
[plugin ] problem with paths used in plugin [message #553342] Tue, 17 August 2010 04:31 Go to next message
Eclipse User is currently offline Eclipse User
Messages: 34
Registered: July 2010
Member
Hi all !

I've used some paths in my plugin which are specific to me ( for example when reading the content of a file to extract informations that I used ) .
I want to know if there will be a problem when deploying the plugin at end , I'm not sure but I think that other users will not be able to detect the file .
How should I rearrange the paths if there is a problem

Thanks so much !
Re: [plugin ] problem with paths used in plugin [message #553420 is a reply to message #553342] Tue, 17 August 2010 09:29 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

emna.lamine@ensi-bourges.fr wrote:
> Hi all !
>
> I've used some paths in my plugin which are specific to me ( for example
> when reading the content of a file to extract informations that I used ) .
> I want to know if there will be a problem when deploying the plugin at
> end , I'm not sure but I think that other users will not be able to
> detect the file .

Plugins can include files either as resources (the standard java way,
simply files in the source tree that can be loaded from
getResourceAsStream(*)) or simply loaded as files from the bundle (like
most plugin's icons/ directory) using Bundle#getEntry(*).

Both of the above methods work during development and during deployment
(when the plugin is a jar).

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: [plugin ] problem with paths used in plugin [message #553439 is a reply to message #553420] Tue, 17 August 2010 10:19 Go to previous messageGo to next message
Eclipse User is currently offline Eclipse User
Messages: 34
Registered: July 2010
Member

so if I read a file this way it won't work when I deploy my plugin ??
FileInputStream myFile = new FileInputStream("/home/..../workspace/..../myFile");


Re: [plugin ] problem with paths used in plugin [message #553517 is a reply to message #553439] Tue, 17 August 2010 14:32 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

emna.lamine@ensi-bourges.fr wrote:
>
> so if I read a file this way it won't work when I deploy my plugin ??
>
> FileInputStream myFile = new
> FileInputStream("/home/..../workspace/..../myFile");

Correct, that's not the kind of file that is in a plugin.

If it's a resource in the classpath, you need getResourceAsStream(*).
If it is file or directory you want to include in your plugin, then you
get your Bundle and use bundle.getEntry(*).

What kind of file are you trying to load?

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: [plugin ] problem with paths used in plugin [message #553546 is a reply to message #553517] Tue, 17 August 2010 18:06 Go to previous messageGo to next message
Eclipse User is currently offline Eclipse User
Messages: 34
Registered: July 2010
Member
Thanks Paul !

I got it Very Happy
I have a file from which I want to read the content. I used this method :

private InputStream openContentStream()
	{
		return this.getClass()
		.getResourceAsStream("/file path in my plugin package ");
	}


then I've done this :
InputStream stream = openContentStream();
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
         .....
stream.close();


Thanks so much for your explanation !!
Re: [plugin ] problem with paths used in plugin [message #553622 is a reply to message #553546] Wed, 18 August 2010 04:35 Go to previous message
Eclipse User is currently offline Eclipse User
Messages: 34
Registered: July 2010
Member
Hello!

another question please that deals also with the paths !
if I checkout a package source from SVN with my code in my plugin I'm obliged to specify a local path where to put the working copy that I created .
What should I do to transforme this location by default to the workspace of the user of my plugin ( the package source should be copied into the user's workspace of eclipse )? is it done automatically ?
my local path is :

File localPath = new File("/home/..../runtime-EclipseApplication/....");


Thanks for your help !
Previous Topic:[plugin] control the position of a command in the toolbar
Next Topic:Two questions about files in bundle and ISpellingEngine
Goto Forum:
  


Current Time: Wed Aug 27 05:14:39 EDT 2014

Powered by FUDForum. Page generated in 0.02756 seconds