Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » E-Mail link
E-Mail link [message #656326] Fri, 25 February 2011 01:59 Go to next message
Eclipse UserFriend
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 03:24 Go to previous messageGo to next message
Eclipse UserFriend
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 05:54 Go to previous messageGo to next message
Eclipse UserFriend
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 03:01] by Moderator

Re: E-Mail link [message #656380 is a reply to message #656373] Fri, 25 February 2011 06:17 Go to previous messageGo to next message
Eclipse UserFriend
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] Fri, 25 February 2011 22:38 Go to previous messageGo to next message
Eclipse UserFriend
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: Fri, 25 February 2011 22:40] by Moderator

Re: E-Mail link [message #656706 is a reply to message #656515] Mon, 28 February 2011 03:29 Go to previous messageGo to next message
Eclipse UserFriend
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] Sat, 12 March 2011 23:17 Go to previous message
Eclipse UserFriend
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: Tue Jul 08 03:39:26 EDT 2025

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

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

Back to the top