Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Displaying a webpage in a view(How to display a webpage in a view)
Displaying a webpage in a view [message #829033] Sun, 25 March 2012 19:13 Go to next message
alan a is currently offline alan aFriend
Messages: 2
Registered: March 2012
Junior Member
Hi,

i am trying to display(render) a webpage in my view, but i can't get it working. I have done the following so far:

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

public class SampleView extends ViewPart {

	private TableViewer viewer;
	private Browser browser;


	public void createPartControl(Composite parent) {
		GridLayout layout = new GridLayout(1, false);
		browser = new Browser(parent, SWT.NONE);
		parent.setLayout(layout);
		createViewer(parent);
	}

	private void createViewer(Composite parent) {
		viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
		browser.setBounds(0, 0, 500, 200);
		browser.setUrl("google com");
		viewer.add(browser);

	}

	public void setFocus() {
		viewer.getControl().setFocus();
	}
}


The result can be seen in the following screenshot:
index.php/fa/7647/0/

- How can i get ride of the small rectangle that contains the text "Browser{}" ?
- Is it possible to set the browser window size to fit automatically to the current view's size?


Thanks in advance.

[Updated on: Sun, 25 March 2012 19:14]

Report message to a moderator

Re: Displaying a webpage in a view [message #829099 is a reply to message #829033] Sun, 25 March 2012 21:41 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
This works for me:

package tt.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;


public class SampleView extends ViewPart {

public static final String ID = "tt.views.SampleView";

private Browser browser;

public SampleView() {
}

public void createPartControl(Composite parent) {
browser = new Browser(parent, SWT.NONE);
parent.setLayout(new FillLayout());
browser.setUrl("google.com");
}

public void setFocus() {
browser.setFocus();
}
}

Do You really need a TableViewer?

Regards
Mauro

On 25/03/2012 21:13, alan a wrote:
> Hi,
>
> i am trying to display(render) a webpage in my view, but i can't get it working. I have done the following so far:
>
>
> import org.eclipse.jface.viewers.TableViewer;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.browser.Browser;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.ui.part.ViewPart;
>
> public class SampleView extends ViewPart {
>
> private TableViewer viewer;
> private Browser browser;
>
>
> public void createPartControl(Composite parent) {
> GridLayout layout = new GridLayout(1, false);
> browser = new Browser(parent, SWT.NONE);
> parent.setLayout(layout);
> createViewer(parent);
> }
>
> private void createViewer(Composite parent) {
> viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
> browser.setBounds(0, 0, 500, 200);
> browser.setUrl("google com");
> viewer.add(browser);
>
> }
>
> public void setFocus() {
> viewer.getControl().setFocus();
> }
> }
>
>
> The result can be seen in the following screenshot:
> s18.postimage.org/pw46hwfbd/Browser_View.jpg
>
>
> - How can i get ride of the small rectangle that contains the text "Browser{}" ?
> - Is it possible to set the browser window size to fit automatically to the current view's size?
>
>
> Thanks in advance.
Re: Displaying a webpage in a view [message #829521 is a reply to message #829033] Mon, 26 March 2012 11:59 Go to previous message
alan a is currently offline alan aFriend
Messages: 2
Registered: March 2012
Junior Member
Thanks Mauro. That was exactly what i was looking for.
Previous Topic:RCP application architecture
Next Topic:java.lang.VerifyError:
Goto Forum:
  


Current Time: Mon Nov 30 08:59:34 GMT 2020

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

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

Back to the top