Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Open new window/popup and show custom html with css
Open new window/popup and show custom html with css [message #1837142] Fri, 22 January 2021 11:17 Go to next message
Eclipse UserFriend
Hi guys,

Is it possible to open a new popup/window and show custom html + css? We need to enable printing custom html/css.

So let's say I've got some html + css code and when the user clicks on a button a new window/popup opens displaying the page using this html + css. With that the user is able to use the print function (CTRL + P) to print the popup's view.

Thanks in Advance,
Chris

[Updated on: Fri, 22 January 2021 11:20] by Moderator

Re: Open new window/popup and show custom html with css [message #1837222 is a reply to message #1837142] Mon, 25 January 2021 07:23 Go to previous messageGo to next message
Eclipse UserFriend
You could use a jface Dialog or PopupDialog which contains an org.eclipse.swt.browser.Browser to show the html + css. Add a button or action to the dialog which calls Browser#evaluate with "window.print();" as script to execute on that browser instance.
It worked for me that way (to only print the iframe's content).

[Updated on: Tue, 26 January 2021 10:35] by Moderator

Re: Open new window/popup and show custom html with css [message #1838407 is a reply to message #1837142] Wed, 24 February 2021 06:56 Go to previous message
Eclipse UserFriend
Hi Chris,

I basically do it in the same way as Sebastian suggested. I open a new popup Dialog (based on the org.eclipse.jface.dialogs.Dialog class), add a org.eclipse.swt.browser.Browser widget, apply a layout on it so it fills the whole space of the dialog (and increases size automatically with it) and then add the HTML payload to it using the Browser#setText method.

String htmlWithCss = createHtmlContent()
Browser browser = new Browser(parent, SWT.NONE);
browser.setText(htmlWithCss);
GridDataBuilder.on(browser).withFill();


The Browser widget renders the HTML it gets via #setText in an iframe, so it can contain whatever HTML, CSS and JS and even refer to static resources by URL. So I basically generate a <html></html> page to display my stuff. You could then inline the CSS in the header section and add the HTML in the body section. Works pretty well.

HTH,
Ben

[Updated on: Wed, 24 February 2021 06:57] by Moderator

Previous Topic:Custom RichTextEditor Fontsizes
Next Topic:Eclipse RAP application in horizontally scaled Azure WebApp Container
Goto Forum:
  


Current Time: Wed May 07 14:52:28 EDT 2025

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

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

Back to the top