Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Loading a non-properties files from a fragment into and editor
Loading a non-properties files from a fragment into and editor [message #326093] Fri, 07 March 2008 09:58 Go to next message
Lila Aravopoulos is currently offline Lila AravopoulosFriend
Messages: 13
Registered: July 2009
Junior Member
I have a html file that is translated and its translated copies reside in
my plugin fragment. I need to open it in an editor. The English version of
the file is at the root of my plugin. Currently I am using this code to
locat the file url, where relativePath is the file name:

public URL getURLFromFragment(relativePath){
Bundle bundle = Platform.getBundle(MY_PLUGIN_ID);
try{
IPath path = new Path("$nl$/"+relativePath);
URL url = FileLocator.find(bundle, path, null);
return url;
}
catch (Exception exc) {
exc.printStackTrace();
return null;
}


}

Then I instantiate my editor input class, a subclass of IPathEditorInput,
with a Path object built from the url returned my method above like:

myEditorInput editor = new myEditorInput(new
Path(getURLFromFragment("myFileName")));

This currently only opens the English version of the file! Anyone has any
idea why? Do I need to read in the file as an inputStream and then somehow
display it. I am thinking something must be wrong with how I am
instantiating my editor input class.

Any help is truly appreciated...
Re: Loading a non-properties files from a fragment into and editor [message #326103 is a reply to message #326093] Fri, 07 March 2008 10:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Lila,

What does the folder structure in your plugin for the translated
versions look like? Did you use the -nl flag to direct Eclipse to use a
different locale?


Lila wrote:
> I have a html file that is translated and its translated copies reside
> in my plugin fragment. I need to open it in an editor. The English
> version of the file is at the root of my plugin. Currently I am using
> this code to locat the file url, where relativePath is the file name:
>
> public URL getURLFromFragment(relativePath){
> Bundle bundle = Platform.getBundle(MY_PLUGIN_ID);
> try{
> IPath path = new Path("$nl$/"+relativePath);
> URL url = FileLocator.find(bundle, path, null);
> return url;
> }
> catch (Exception exc) {
> exc.printStackTrace(); return null;
> }
>
> }
> Then I instantiate my editor input class, a subclass of
> IPathEditorInput, with a Path object built from the url returned my
> method above like:
>
> myEditorInput editor = new myEditorInput(new
> Path(getURLFromFragment("myFileName")));
>
> This currently only opens the English version of the file! Anyone has
> any idea why? Do I need to read in the file as an inputStream and then
> somehow display it. I am thinking something must be wrong with how I
> am instantiating my editor input class.
>
> Any help is truly appreciated...
>
Re: Loading a non-properties files from a fragment into and editor [message #326109 is a reply to message #326103] Fri, 07 March 2008 12:30 Go to previous messageGo to next message
Lila Aravopoulos is currently offline Lila AravopoulosFriend
Messages: 13
Registered: July 2009
Junior Member
I actually put the translated files under a nl\local directory structure
like this in the NL fragment plugin:

nl\de\myfile.html
nl\es\myfile.html
nl\zh\hk\myfile.html
..
..
..


I know that you can place the files at the root of the fragment like
myfile_zh_hk.html, myfile_de.html, etc.
Re: Loading a non-properties files from a fragment into and editor [message #326117 is a reply to message #326109] Fri, 07 March 2008 13:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Lila,

You might need to specify your path as "nl/$NL$/myfile.html. I'm not
really exactly sure the specific naming conventions that are followed.
Have you tried stepping with the debugger through the lookup logic to
see where it all searches for the path you've provided?


Lila wrote:
> I actually put the translated files under a nl\local directory
> structure like this in the NL fragment plugin:
>
> nl\de\myfile.html
> nl\es\myfile.html
> nl\zh\hk\myfile.html
> .
> .
> .
>
>
> I know that you can place the files at the root of the fragment like
> myfile_zh_hk.html, myfile_de.html, etc.
>
Re: Loading a non-properties files from a fragment into and editor [message #326124 is a reply to message #326109] Fri, 07 March 2008 13:40 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

and you started your eclipse with -nl de?

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Display actions when a project has a certain file
Next Topic:compare with revision/compare examples
Goto Forum:
  


Current Time: Sun Jun 30 00:03:29 GMT 2024

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

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

Back to the top