Notification window allow you to display custom message toasts, alerts to the user from your plug-in. This sample specifies the steps required to use Notification window in your plug-ins.
Step1: Add the following dependencies to the plug-in:
com.ibm.collaboration.realtime.magiccarpet;
com.ibm.collaboration.realtime.people;
com.ibm.collaboration.realtime.ui;
Step2: Add the following import statements to the java class file:
import com.ibm.collaboration.realtime.magiccarpet.MessageEvent;
import com.ibm.collaboration.realtime.magiccarpet.MessageEventConstants;
import com.ibm.collaboration.realtime.magiccarpet.messageprocessor.MessageProcessor;
import com.ibm.collaboration.realtime.people.alerts.Alert;
import com.ibm.collaboration.realtime.ui.AlertInfo;
Step3: Add the following function to the class. Notification window will be displayed when the following function is called:
public static void showAlert (final String title,
final String message,
final String alertType,
final Color highlightColor,
final boolean showNearTray,
final Image alertImage,
final Image alertIcon) {
try {
Display.getDefault().asyncExec( new Runnable () {
public void run () {
Alert alert = new Alert();
alert.setBubble(true);
alert.setDefaultToneSetting(true);
alert.setEvent(0);
alert.setNoteText(message);
alert.setRecurring(false);
//Configure AlertInfo
AlertInfo alertInfo = new AlertInfo();
alertInfo.setIsPreview(true);
alertInfo.setTitle(title);
alertInfo.setSenderId(alertType);
alertInfo.setSubjectBarText(alertType);
alertInfo.setMessageImage(alertImage);
alertInfo.setIcon(alertIcon);
alertInfo.setMessage(message);
alertInfo.setHighlightColor(highlightColor.getRGB());
alertInfo.setPlaySound(alert.getDefaultToneSetting());
alertInfo.setPreviewSlideEffect(true);
alertInfo.setPreviewAutoClose(true);
if (showNearTray)
{
alertInfo.setPreviewBubbleAppearance(2);
}
else
{
alertInfo.setPreviewBubbleAppearance(1);
}
alertInfo.setPreviewFlashTaskbar(true);
alertInfo.setPreviewBringWindowToFront(true);
MessageEvent messageEvent = new MessageEvent(MessageEventConstants.AlertUser);
messageEvent.setProperty("alert_info_key", alertInfo);
messageEvent.setProperty("alert_settings_key", "/app/imhub/alertuser");
MessageProcessor.getInstance().postMessageEvent(messageEvent);
}});
} catch (Exception ex) {
ex.printStackTrace();
}
}
You can tweak the function as per your requirement.