Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Rich content in desktop notifications
Rich content in desktop notifications [message #1806461] Thu, 09 May 2019 12:06 Go to next message
Krzysztof Leja is currently offline Krzysztof LejaFriend
Messages: 22
Registered: April 2019
Junior Member
Hi,
Is it possible to include richer content (eg icons, buttons, html content) in the desktop notification - triggered by ClientSession.get().getDesktop().addNotification() - such as in a popup?

In the example from the page https://scout.bsi-software.com/widgets/?dl=widget-desktop I can see that you can include only simple text in the notification. But when, for example, I click "View source on GitHub" there, it displays notification "Opening a new window automatically was blocked by the browser" with an additional "Open manually" button. This would indicate that there is some method to add additional elements to the notification.
Re: Rich content in desktop notifications [message #1806557 is a reply to message #1806461] Fri, 10 May 2019 10:59 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 59
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Member
Hi Krzysztof

Yes, when you take a look at the JavaScript source-code in PopupBlockerHandler#showNotification, you'll see that a "variant" of DesktopNotification.js is created instead of the regular Notification:

notification = scout.create('DesktopNotification:PopupBlocker', {
    parent: desktop,
    linkUrl: linkUrl,
    preserveOpener: this.preserveOpener
  });


This instantiates the class PopupBlockerDesktopNotification.js, where the _render function creates the HTML you mentioned in your post.

In a Scout Java application you could use a @ModelVariant to mark a specific Notification class, like this:

@ModelVariant("Special")
class SpecialDesktopNotification extends DesktopNotification {
  public SpecialDesktopNotification(IStatus status, long duration, boolean closable) {
    super(status, duration, closable);
  }
}


And add the notification like this:

DesktopNotification notification = new SpecialDesktopNotification(status, duration, closeable);
ClientSession.get().getDesktop().addNotification(notification);


In your *.ui.html project you need to add a JavaScript class "SpecialDesktopNotification.js" that extends DesktopNotification.js and register it in your module.js. Scout finds and instantiates this class by name-magic. In that class you can override the _render or _renderMessage function and implement whatever you need. A very simple approach could override _renderMessage and simply add the message from the status object as HTML, without encoding HTML as DesktopNotification.js does. Example:

scout.SpecialDesktopNotification.prototype._renderMessage = function() {
  var html = scout.nvl(this.status.message, '');
  this.$messageText.html(html);
};


André


Eclipse Scout Homepage | Documentation | GitHub
Re: Rich content in desktop notifications [message #1806563 is a reply to message #1806557] Fri, 10 May 2019 11:55 Go to previous messageGo to next message
Krzysztof Leja is currently offline Krzysztof LejaFriend
Messages: 22
Registered: April 2019
Junior Member
Hi Andre,

Thank you for a detailed description of the solution for my case.
I will try to use your example with HTML content. It will do the job.

PS. Assuming you are from the development team of the Eclipse scout platform, I will ask you: are there any plans to add native support for richer notifications in the next releases of this platform?
I think that this would be often used functionality.
In particular, it would be nice to be able to display an additional icon in these notifications, in order to better illustrate to the user what the notification is about.
Re: Rich content in desktop notifications [message #1806568 is a reply to message #1806563] Fri, 10 May 2019 12:28 Go to previous message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 59
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Member
You're welcome.

Currently there's no specific plan to enhance the DesktopNotification. But I like the idea of making the notification more flexible, and while I was writing the post above, I thought it would be a good idea to add at least a "htmlEnabled" property. Some other widgets, like LabelField.js, already have that property, which allows to provide HTML content instead of plain text.

I'll add this (and your proposal about icon support) to our backlog.


Eclipse Scout Homepage | Documentation | GitHub
Previous Topic:Authentication in Scout 8
Next Topic:Eclipse Scout 8.0 application with two clients
Goto Forum:
  


Current Time: Sat Oct 19 15:04:09 GMT 2019

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

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

Back to the top