Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Program.findProgram() returns null
Program.findProgram() returns null [message #446262] Tue, 23 November 2004 00:00 Go to next message
Christian Hauser is currently offline Christian HauserFriend
Messages: 189
Registered: July 2009
Senior Member
Hello everybody

I need to open PDF files from an SWT application, but I also would like
to inform the user that he/she needs a program such as Adobe Reader to
open PDF files if no such program is registered for the extension "pdf".

However, the method Program.findProgram("pdf") often returns null even
if there is a program associated with PDF files. The problem mainly
occurs on Windows 2000 and Linux.

Dani had the same problem with HTML files as mentioned in bug 71228:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=71228

Could anyone please give me a hint on how to solve this problem? Might
this get fixed anytime soon? Are there any alternatives on how to open a
PDF file from within an SWT application? I'd rather not use
java.lang.Runtime#exec.

Thanks in advance for any help on how I could solve this problem.

Christian
Re: Program.findProgram() returns null [message #446264 is a reply to message #446262] Tue, 23 November 2004 03:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wkrain.hotmail.com

"Christian Hauser" <c.hauser@active.ch> wrote in message
news:cntujm$j3q$1@www.eclipse.org...
> Hello everybody
>
> I need to open PDF files from an SWT application, but I also would like
> to inform the user that he/she needs a program such as Adobe Reader to
> open PDF files if no such program is registered for the extension "pdf".
>
> However, the method Program.findProgram("pdf") often returns null even
> if there is a program associated with PDF files. The problem mainly
> occurs on Windows 2000 and Linux.
>
> Dani had the same problem with HTML files as mentioned in bug 71228:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=71228
>
> Could anyone please give me a hint on how to solve this problem? Might
> this get fixed anytime soon? Are there any alternatives on how to open a
> PDF file from within an SWT application? I'd rather not use
> java.lang.Runtime#exec.
>
> Thanks in advance for any help on how I could solve this problem.
>
> Christian
Re: Program.findProgram() returns null [message #446265 is a reply to message #446262] Tue, 23 November 2004 03:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wkrain.hotmail.com

Hi buddy

I can give mw a hint on how to slov this problem,There are an
alternatives on how to open a PDF file from within
an swt application. I need point this mentod is great way to slove your
problem.

You can integrate Activex into SWT application. For example

public class PDFViewer extends ApplicationWindow
{
private OleControlSite site;
private OleAutomation auto;
public PDFViewer()
{
super(null);
this.addMenuBar();
}

protected Control createContents(Composite parent)
{
Shell shell = this.getShell();
shell.setText("PDF Viewer");
shell.setSize(500, 450);
OleFrame frame = new OleFrame(shell, SWT.NONE);
try
{
site = new OleControlSite(frame, SWT.NONE, "PDF.PdfCtrl.5");
auto = new OleAutomation(site);
..........................



public void showPdfControl()
{
site.doVerb(OLE.OLEIVERB_SHOW);
}

public void loadFile(String file)
{
showPdfControl();
int[] rgdispid = auto.getIDsOfNames(newString[]{"LoadFile"});
int dispIdMember = rgdispid[0];

Variant[] rgvarg = new Variant[1];
rgvarg[0] = new Variant(file);
Variant pVarResult =auto.invoke(dispIdMember,rgvarg);
}

I hope so this article will help you slove your problem!


"Christian Hauser" <c.hauser@active.ch> wrote in message
news:cntujm$j3q$1@www.eclipse.org...
> Hello everybody
>
> I need to open PDF files from an SWT application, but I also would like
> to inform the user that he/she needs a program such as Adobe Reader to
> open PDF files if no such program is registered for the extension "pdf".
>
> However, the method Program.findProgram("pdf") often returns null even
> if there is a program associated with PDF files. The problem mainly
> occurs on Windows 2000 and Linux.
>
> Dani had the same problem with HTML files as mentioned in bug 71228:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=71228
>
> Could anyone please give me a hint on how to solve this problem? Might
> this get fixed anytime soon? Are there any alternatives on how to open a
> PDF file from within an SWT application? I'd rather not use
> java.lang.Runtime#exec.
>
> Thanks in advance for any help on how I could solve this problem.
>
> Christian
Re: Program.findProgram() returns null [message #446290 is a reply to message #446265] Tue, 23 November 2004 07:55 Go to previous messageGo to next message
Christian Hauser is currently offline Christian HauserFriend
Messages: 189
Registered: July 2009
Senior Member
Thanks a lot for your code. I'll try that. However, as this seems to be
a Windows-only solution I'm not sure whether I'll go for it.

Christian


wkrain wrote:
> Hi buddy
>
> I can give mw a hint on how to slov this problem,There are an
> alternatives on how to open a PDF file from within
> an swt application. I need point this mentod is great way to slove your
> problem.
>
> You can integrate Activex into SWT application. For example
>
> public class PDFViewer extends ApplicationWindow
> {
> private OleControlSite site;
> private OleAutomation auto;
> public PDFViewer()
> {
> super(null);
> this.addMenuBar();
> }
>
> protected Control createContents(Composite parent)
> {
> Shell shell = this.getShell();
> shell.setText("PDF Viewer");
> shell.setSize(500, 450);
> OleFrame frame = new OleFrame(shell, SWT.NONE);
> try
> {
> site = new OleControlSite(frame, SWT.NONE, "PDF.PdfCtrl.5");
> auto = new OleAutomation(site);
> .........................
>
>
>
> public void showPdfControl()
> {
> site.doVerb(OLE.OLEIVERB_SHOW);
> }
>
> public void loadFile(String file)
> {
> showPdfControl();
> int[] rgdispid = auto.getIDsOfNames(newString[]{"LoadFile"});
> int dispIdMember = rgdispid[0];
>
> Variant[] rgvarg = new Variant[1];
> rgvarg[0] = new Variant(file);
> Variant pVarResult =auto.invoke(dispIdMember,rgvarg);
> }
>
> I hope so this article will help you slove your problem!
>
>
> "Christian Hauser" <c.hauser@active.ch> wrote in message
> news:cntujm$j3q$1@www.eclipse.org...
>
>>Hello everybody
>>
>>I need to open PDF files from an SWT application, but I also would like
>>to inform the user that he/she needs a program such as Adobe Reader to
>>open PDF files if no such program is registered for the extension "pdf".
>>
>>However, the method Program.findProgram("pdf") often returns null even
>>if there is a program associated with PDF files. The problem mainly
>>occurs on Windows 2000 and Linux.
>>
>>Dani had the same problem with HTML files as mentioned in bug 71228:
>>https://bugs.eclipse.org/bugs/show_bug.cgi?id=71228
>>
>>Could anyone please give me a hint on how to solve this problem? Might
>>this get fixed anytime soon? Are there any alternatives on how to open a
>>PDF file from within an SWT application? I'd rather not use
>>java.lang.Runtime#exec.
>>
>>Thanks in advance for any help on how I could solve this problem.
>>
>>Christian
>
>
>
Re: Program.findProgram() returns null [message #652029 is a reply to message #446290] Wed, 02 February 2011 13:46 Go to previous message
Parvez Ahmad Hakim is currently offline Parvez Ahmad HakimFriend
Messages: 31
Registered: May 2010
Member
Hi,
I want to migrate a RCP to eclipse RAP.
I can not find equivalent code for
Program.findProgram, Program.launch
I also fase problem in porting E4(dia inject) part of code
Can some one help.


regards
Parvez Ahmad Hakim
www.abobjects.com

Previous Topic:how to sort ComboBoxCellEditor in a table
Next Topic:migrating RCP to RAP
Goto Forum:
  


Current Time: Sun Apr 05 06:51:29 GMT 2020

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

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

Back to the top