Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » XULRunner and file handling / mimetypes
XULRunner and file handling / mimetypes [message #647492] Thu, 06 January 2011 16:49 Go to next message
Fabian  is currently offline Fabian Friend
Messages: 3
Registered: January 2011
Junior Member
Hope this is the right forum to post to, appogizes if it is wrong or information is missing.

We are using DJ native swing which is using SWT to include the XULRunner (browser control) in a Swing application.

When we open a link to a pdf, the browser plugin only gives the option to "save file", and not alternatively to "Open in Foxit Reader" (or Acrobat Reader or whatever). When opening the same link in Firefox, it gives both options.

I noticed that there is no mimetypes.rdf in Mozilla/Eclipse directory. Any hints how to configure mime type handling with SWT/Xulrunner?

Versions:
Windows XP
swt 3.6-M7
djnative-swing" rev="0.9.9.20100523"
XulRunner 1.9.2.3705

Thanks in advance!

- Fabian

Re: XULRunner and file handling / mimetypes [message #647948 is a reply to message #647492] Mon, 10 January 2011 15:02 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Fabian,

If the plugin is installed on your machine then it should be found by the
Browser. I've confirmed that clicking a link to a .pdf opens Acrobat Reader
for me with the SWT 3.6 release, which should not be too different from
3.6M7. Maybe djnative-swing is interfering with this somehow (not sure why
it would). Anyways, as a workaround you can augment the plugin search path
as described in http://www.eclipse.org/swt/faq.php#mozillaplugins .

Grant


"Fabian" <fn@blau.de> wrote in message news:ig4rhh$o4m$1@news.eclipse.org...
> Hope this is the right forum to post to, appogizes if it is wrong or
> information is missing.
>
> We are using DJ native swing which is using SWT to include the XULRunner
> (browser control) in a Swing application.
>
> When we open a link to a pdf, the browser plugin only gives the option to
> "save file", and not alternatively to "Open in Foxit Reader" (or Acrobat
> Reader or whatever). When opening the same link in Firefox, it gives both
> options.
> I noticed that there is no mimetypes.rdf in Mozilla/Eclipse directory. Any
> hints how to configure mime type handling with SWT/Xulrunner?
>
> Versions:
> Windows XP
> swt 3.6-M7
> djnative-swing" rev="0.9.9.20100523"
> XulRunner 1.9.2.3705
>
> Thanks in advance!
>
> - Fabian
>
>
Re: XULRunner and file handling / mimetypes [message #652370 is a reply to message #647948] Thu, 03 February 2011 17:08 Go to previous messageGo to next message
Fabian  is currently offline Fabian Friend
Messages: 3
Registered: January 2011
Junior Member
Hi Grant, many thanks for your reply!

As far as I can see, I don't want to use a plugin. I set the variable MOZ_PLUGIN_PATH to point to nppdf32.dll (Acrobat Reader plugin), which is working fine and displays PDFs inline.

Though, I would like to open the PDF with the external system default application. I would like to configure a "save action", as I would do with firefox => settings => applications (as stored in mimetypes.rdf).

I get the impression that this is a firefox feature, which is not available in stand alone xulrunner.

Any ideas / suggestions?

Thanks!

- Fabian

[Updated on: Thu, 03 February 2011 17:15]

Report message to a moderator

Re: XULRunner and file handling / mimetypes [message #652633 is a reply to message #652370] Fri, 04 February 2011 19:08 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
To do this you would need to use JavaXPCOM to provide a custom nsIHelperAppLauncherDialog implementation to XULRunner. This implementation would be notified whenever a url's content was to be downloaded, and in response could either return a file system location of its choice to download the content to, or open a file dialog to allow the user to choose. After downloading the file you could open it with its OS-registered viewer/editor either with SWT's Program.launch() method or with the Swing equivalent.

To auto-open the file when its download completed you would also need to implement a custom download handler. For an example of one of these see http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.sn ippets/src/org/eclipse/swt/snippets/Snippet277.java?view=co . Note that the top of this snippet also has a link to info about using JavaXPCOM in general. There is not a similar link that demonstrates providing your own nsIHelperAppLauncherDialog implementation, but you can see the source of SWT's Mozilla and HelperAppLauncherDialog/HelperAppLauncherDialog_1_9 classes to see how the Browser does it via XPCOM.

Whether it's worth the effort to try and implement this depends on how important this functionality is to your app. If you decide to give it a try and have specific questions along the way then feel free to ask here. If you do decide to try it, note that the nsIDownload and nsIHelperAppLauncherDialog interfaces have changed across various XULRunner versions, so you'll need to make sure that you compile against a XULRunner SDK that matches the version of XULRunner that's shipped in DJSwing. The example download handler linked above works with XULRunner 1.8.1.3, but it's possible that the XULRunner shipped with DJSwing is newer than this.

HTH,
Grant
Re: XULRunner and file handling / mimetypes [message #652802 is a reply to message #652633] Sun, 06 February 2011 23:04 Go to previous message
Fabian  is currently offline Fabian Friend
Messages: 3
Registered: January 2011
Junior Member
Grant, thank you a lot for the detailed explanation!

- Fabian



Previous Topic:Off-screen buffering?
Next Topic:Validation in SWT DateTime widget?
Goto Forum:
  


Current Time: Tue Mar 31 17:35:32 GMT 2020

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

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

Back to the top