Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » E-Mail link
E-Mail link [message #656326] Fri, 25 February 2011 06:59 Go to next message
KwanKin Yau is currently offline KwanKin YauFriend
Messages: 32
Registered: July 2009
Member
Hi,

I want to create a e-mail link widget, like following code:
		Link link = new Link(tb, SWT.NONE);
		link.setText("<a href=\"mailto:alphax@vip.163.com\">alphax</a>");		
		link.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
		link.addSelectionListener(new SelectionAdapter() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				int style = ExternalBrowser.LOCATION_BAR
                | ExternalBrowser.NAVIGATION_BAR
                | ExternalBrowser.STATUS;
				
				
				String url = "mailto:alphax@vip.163.com";
				ExternalBrowser.open( "mailToAlphax", url, style );
			}
		});


But this code will open an new empty browser window, and then invoke the e-mail client. What I want just invoke the mail client when the user click on the link, How to achieve this?

Need your help, thanks!
Re: E-Mail link [message #656343 is a reply to message #656326] Fri, 25 February 2011 08:24 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
to avoid the new browser window you can use a Browser widget. Set the
text to it like Browser#setText( "<a
href=\"mailto:alphax@vip.163.com\">alphax</a>" );. You can use the <a>
inline "style" attribute to change the look of the link (font, color...).
HTH,
Ivan


On 2/25/2011 8:59 AM, Yau wrote:
> Hi,
>
> I want to create a e-mail link widget, like following code:
>
> Link link = new Link(tb, SWT.NONE);
> link.setText("<a href=\"mailto:alphax@vip.163.com\">alphax</a>");
> link.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
> false));
> link.addSelectionListener(new SelectionAdapter() {
>
> @Override
> public void widgetSelected(SelectionEvent e) {
> int style = ExternalBrowser.LOCATION_BAR
> | ExternalBrowser.NAVIGATION_BAR
> | ExternalBrowser.STATUS;
>
>
> String url = "mailto:alphax@vip.163.com";
> ExternalBrowser.open( "mailToAlphax", url, style );
> }
> });
>
>
> But this code will open an new empty browser window, and then invoke
> the e-mail client. What I want just invoke the mail client when the
> user click on the link, How to achieve this?
>
> Need your help, thanks!
Re: E-Mail link [message #656373 is a reply to message #656343] Fri, 25 February 2011 10:54 Go to previous messageGo to next message
KwanKin Yau is currently offline KwanKin YauFriend
Messages: 32
Registered: July 2009
Member
Thanks your advice, but the size of the browser widget is too large for my situation.

Is it possible add an "mailto" javascript to the respond stream to achieve an mail client invocation? I am not familiar with javascript.

[Updated on: Mon, 28 February 2011 08:01]

Report message to a moderator

Re: E-Mail link [message #656380 is a reply to message #656373] Fri, 25 February 2011 11:17 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Yau,
to my knowledge, the only possible solution without writing a custom
widget is to use the Browser widget. What do you mean by "browser widget
is too large"? You can set the size to whatever you want.
Best,
Ivan

On 2/25/2011 12:54 PM, Yau wrote:
> Thanks your advice, but the size of the browser widget is too large
> for my situation.
>
> Is it possible add an "mailto" javascript to the respond stream to
> achieve an mail client invocation? I am not favorite with javascript.
Re: E-Mail link [message #656515 is a reply to message #656380] Sat, 26 February 2011 03:38 Go to previous messageGo to next message
KwanKin Yau is currently offline KwanKin YauFriend
Messages: 32
Registered: July 2009
Member
Thanks Ivan,

I use this email link in the status line, if use Browser widget, I want it act as the Link widget, just draw a single line text but without scroll bar.

As the code as below, even I have specified SWT.NO_SCOLL as the browser style, but the code produce an small scroll bar, and the scroll bar occupied the all space so that the link text is invisible.
StatusLineContributionItem.fill(...) {
		Composite panel = new Composite(parent, SWT.NONE);
		panel.setLayout(new GridLayout(3, false));

		Label label = new Label(panel, SWT.NONE);
		label.setText("Copy right");
		label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));

		Browser browser = new Browser(panel, SWT.NO_SCROLL);
		browser.setText("<a href=\"mailto:alphax@vip.163.com\">alphax</a>");
		browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		label = new Label(panel, SWT.NONE);
		label.setText("2011");
		label.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, false, false));

}

[Updated on: Sat, 26 February 2011 03:40]

Report message to a moderator

Re: E-Mail link [message #656706 is a reply to message #656515] Mon, 28 February 2011 08:29 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
you could try to play with <a> inline css like:
<a style="...">
to change the link font size, padding and so on...
HTH,
Ivan
Re: E-Mail link [message #659374 is a reply to message #656706] Sun, 13 March 2011 04:17 Go to previous message
KwanKin Yau is currently offline KwanKin YauFriend
Messages: 32
Registered: July 2009
Member
Thank you,you are right, it works now. Razz
Previous Topic:Runtime issue on rendering images in table?
Next Topic:[Wizard]: TableViewer selectionProvider inside a Wizard
Goto Forum:
  


Current Time: Fri Oct 22 14:15:02 GMT 2021

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

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

Back to the top