2

Wonder if somebody can help me with this. I am trying to open an embedded browser in an Eclipse RAP applications. All examples I have seen look something like:

link.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent event) {
        try {
            Browser b = new Browser(parent, SWT.NONE);
            b.setText("<html><body>This is Unicode HTML content from memory</body></html>"); 
        } catch (SWTError e) {
            // Error handling here
        }

    }
});

That doesn't do anything (visually) though. When I replace the Browser with ExternalBrowser like so:

link.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent event) {
        try {
            int browserStyle = ExternalBrowser.LOCATION_BAR;
            ExternalBrowser.open( "myPage", "http://www.stackoverflow.com", browserStyle );
        } catch (SWTError e) {
              // Error handling here
        }

    }
});

It works. Although not exactly as desired.

I am using Eclipse RCP 1.4.2 on OS X 10.8.2.

Any insight is highly appreciated.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • A related answer: http://stackoverflow.com/questions/16483900/display-a-swt-browser-programmatically-from-plugin/16484650#16484650 – Vince May 14 '13 at 08:38

1 Answers1

1

When you create a new widget, you have to trigger a re-layout to make it visible. Depending on your layout, it may be sufficient to call parent.layout(). If the parent is also contained in a layout and shrunken to its preferred size, you will have to call layout() on its parent. If unsure, layout the top-level shell.

ralfstx
  • 3,893
  • 2
  • 25
  • 41