Example usage for com.vaadin.ui Notification Notification

List of usage examples for com.vaadin.ui Notification Notification

Introduction

In this page you can find the example usage for com.vaadin.ui Notification Notification.

Prototype

public Notification(String caption, String description, Type type) 

Source Link

Document

Creates a notification message of the specified type, with a bigger caption and smaller description.

Usage

From source file:annis.gui.exporter.TextColumnExporter.java

License:Apache License

/**
 * Writes the specified record (if applicable, as multiple result lines) from
 * query result set to the output file./*w w  w  . ja  v  a 2 s .co  m*/
 * 
 * @param graph        the org.corpus_tools.salt.common.SDocumentGraph
 *                     representation of a specified record
 * @param alignmc      a boolean, which indicates, whether the data should be
 *                     aligned by match numbers or not
 * @param recordNumber the number of record within the record set
 * @param out          the specified Writer
 * 
 * @throws IOException, if an I/O error occurs
 * 
 */

@Override
public void outputText(SDocumentGraph graph, boolean alignmc, int recordNumber, Writer out) throws IOException {

    String currSpeakerName = "";
    String prevSpeakerName = "";

    if (graph != null) {
        List<SToken> orderedToken = graph.getSortedTokenByText();

        if (orderedToken != null) {

            // iterate over token
            ListIterator<SToken> it = orderedToken.listIterator();
            long lastTokenWasMatched = -1;
            boolean noPreviousTokenInLine = false;

            // if match number == 0, reset global variables and output warning, if necessary
            if (recordNumber == 0) {
                isFirstSpeakerWithMatch = true;
                counterGlobal = 0;

                // create warning message
                String numbersString = "";
                String warnMessage = "";
                StringBuilder sb = new StringBuilder();

                List<Integer> copyOfFilterNumbersSetByUser = new ArrayList<Integer>();

                for (Long filterNumber : filterNumbersSetByUser) {
                    copyOfFilterNumbersSetByUser.add(Integer.parseInt(String.valueOf(filterNumber)));
                }

                for (Integer matchNumberGlobal : matchNumbersGlobal) {
                    copyOfFilterNumbersSetByUser.remove(matchNumberGlobal);
                }

                Collections.sort(copyOfFilterNumbersSetByUser);

                if (!copyOfFilterNumbersSetByUser.isEmpty()) {
                    for (Integer filterNumber : copyOfFilterNumbersSetByUser) {
                        sb.append(filterNumber + ", ");
                    }

                    if (copyOfFilterNumbersSetByUser.size() == 1) {
                        numbersString = "number";
                    } else {
                        numbersString = "numbers";
                    }

                    warnMessage = "1. Filter " + numbersString + " "
                            + sb.toString().substring(0, sb.lastIndexOf(",")) + " couldn't be represented.";

                }

                if (alignmc && !dataIsAlignable) {
                    if (!warnMessage.isEmpty()) {
                        warnMessage += (NEWLINE + NEWLINE + "2. ");
                    } else {
                        warnMessage += "1. ";
                    }

                    warnMessage += "You have tried to align matches by node number via check box."
                            + "Unfortunately this option is not applicable for this data set, "
                            + "so the data couldn't be aligned.";

                }

                if (!warnMessage.isEmpty()) {

                    String warnCaption = "Some export options couldn't be realized.";
                    Notification warn = new Notification(warnCaption, warnMessage,
                            Notification.Type.WARNING_MESSAGE);
                    warn.setDelayMsec(20000);
                    warn.show(Page.getCurrent());
                }
            } // global variables reset; warning issued

            int matchesWrittenForSpeaker = 0;

            while (it.hasNext()) {
                SToken tok = it.next();
                counterGlobal++;
                // get current speaker name
                String name;
                if ((name = CommonHelper.getTextualDSForNode(tok, graph).getName()) == null) {
                    name = "";
                }

                currSpeakerName = (recordNumber + 1) + "_" + name;

                // if speaker has no matches, skip token
                if (speakerHasMatches.get(currSpeakerName) == false) {
                    prevSpeakerName = currSpeakerName;
                    // continue;
                }

                // if speaker has matches
                else {

                    // if the current speaker is new, write header and append his name
                    if (!currSpeakerName.equals(prevSpeakerName)) {
                        // reset the counter of matches, which were written for this speaker
                        matchesWrittenForSpeaker = 0;

                        if (isFirstSpeakerWithMatch) {

                            out.append("match_number" + TAB_MARK);
                            out.append("speaker" + TAB_MARK);

                            // write header for meta data columns
                            if (!listOfMetakeys.isEmpty()) {
                                for (String metakey : listOfMetakeys) {
                                    out.append(metakey + TAB_MARK);
                                }
                            }

                            out.append("left_context" + TAB_MARK);

                            String prefixAlignmc = "match_";
                            String prefix = "match_column";
                            String middle_context = "middle_context_";

                            if (alignmc && dataIsAlignable) {

                                for (int i = 0; i < orderedMatchNumbersGlobal.size(); i++) {
                                    out.append(prefixAlignmc + orderedMatchNumbersGlobal.get(i) + TAB_MARK);

                                    if (i < orderedMatchNumbersGlobal.size() - 1) {
                                        out.append(middle_context + (i + 1) + TAB_MARK);
                                    }
                                }
                            } else {

                                for (int i = 0; i < maxMatchesPerLine; i++) {
                                    out.append(prefix + TAB_MARK);

                                    if (i < (maxMatchesPerLine - 1)) {
                                        out.append(middle_context + (i + 1) + TAB_MARK);
                                    }
                                }

                            }

                            out.append("right_context");
                            out.append(NEWLINE);

                            isFirstSpeakerWithMatch = false;
                        } else {
                            out.append(NEWLINE);
                        }

                        out.append(String.valueOf(recordNumber + 1) + TAB_MARK);

                        String trimmedName = "";
                        if (currSpeakerName.indexOf("_") < currSpeakerName.length()) {
                            trimmedName = currSpeakerName.substring(currSpeakerName.indexOf("_") + 1);
                        }

                        out.append(trimmedName + TAB_MARK);

                        // write meta data
                        if (!listOfMetakeys.isEmpty()) {
                            // get metadata
                            String docName = graph.getDocument().getName();
                            List<String> corpusPath = CommonHelper.getCorpusPath(graph.getDocument().getGraph(),
                                    graph.getDocument());
                            String corpusName = corpusPath.get(corpusPath.size() - 1);
                            corpusName = urlPathEscape.escape(corpusName);
                            List<Annotation> metadata = Helper.getMetaData(corpusName, docName);

                            Map<String, String> annosWithoutNamespace = new HashMap<String, String>();
                            Map<String, Map<String, String>> annosWithNamespace = new HashMap<String, Map<String, String>>();

                            // put metadata annotations into hash maps for better access
                            for (Annotation metaAnno : metadata) {
                                String ns;
                                Map<String, String> data = new HashMap<String, String>();
                                data.put(metaAnno.getName(), metaAnno.getValue());

                                // a namespace is present
                                if ((ns = metaAnno.getNamespace()) != null && !ns.isEmpty()) {
                                    Map<String, String> nsMetadata = new HashMap<String, String>();

                                    if (annosWithNamespace.get(ns) != null) {
                                        nsMetadata = annosWithNamespace.get(ns);
                                    }
                                    nsMetadata.putAll(data);
                                    annosWithNamespace.put(ns, nsMetadata);
                                } else {
                                    annosWithoutNamespace.putAll(data);
                                }

                            }

                            for (String metakey : listOfMetakeys) {
                                String metaValue = "";

                                // try to get meta value specific for current speaker
                                if (!trimmedName.isEmpty() && annosWithNamespace.containsKey(trimmedName)) {

                                    Map<String, String> speakerAnnos = annosWithNamespace.get(trimmedName);
                                    if (speakerAnnos.containsKey(metakey)) {
                                        metaValue = speakerAnnos.get(metakey).trim();
                                    }
                                }

                                // try to get meta value, if metaValue is not set
                                if (metaValue.isEmpty() && annosWithoutNamespace.containsKey(metakey)) {
                                    metaValue = annosWithoutNamespace.get(metakey).trim();
                                }
                                out.append(metaValue + TAB_MARK);
                            }
                        } // metadata written

                        lastTokenWasMatched = -1;
                        noPreviousTokenInLine = true;

                    } // header, speaker name and metadata ready

                    String separator = SPACE; // default to space as separator

                    Long matchedNode;
                    // token matched
                    if ((matchedNode = tokenToMatchNumber.get(counterGlobal)) != null) {
                        // is dominated by a (new) matched node, thus use tab to separate the
                        // non-matches from the matches
                        if (lastTokenWasMatched < 0) {
                            if (alignmc && dataIsAlignable) {
                                int orderInList = orderedMatchNumbersGlobal.indexOf(matchedNode);
                                if (orderInList >= matchesWrittenForSpeaker) {
                                    int diff = orderInList - matchesWrittenForSpeaker;
                                    matchesWrittenForSpeaker++;

                                    StringBuilder sb = new StringBuilder(TAB_MARK);
                                    for (int i = 0; i < diff; i++) {
                                        sb.append(TAB_MARK + TAB_MARK);
                                        matchesWrittenForSpeaker++;
                                    }
                                    separator = sb.toString();
                                }

                            } else {
                                separator = TAB_MARK;
                            }

                        } else if (lastTokenWasMatched != matchedNode) {
                            // always leave an empty column between two matches, even if there is no actual
                            // context
                            if (alignmc && dataIsAlignable) {
                                int orderInList = orderedMatchNumbersGlobal.indexOf(matchedNode);
                                if (orderInList >= matchesWrittenForSpeaker) {
                                    int diff = orderInList - matchesWrittenForSpeaker;
                                    matchesWrittenForSpeaker++;

                                    StringBuilder sb = new StringBuilder(TAB_MARK + TAB_MARK);
                                    for (int i = 0; i < diff; i++) {
                                        sb.append(TAB_MARK + TAB_MARK);
                                        matchesWrittenForSpeaker++;
                                    }

                                    separator = sb.toString();

                                }

                            } else {

                                separator = TAB_MARK + TAB_MARK;
                            }

                        }
                        lastTokenWasMatched = matchedNode;
                    }
                    // token not matched, but last token matched
                    else if (lastTokenWasMatched >= 0) {

                        // handle crossing edges
                        if (!tokenToMatchNumber.containsKey(counterGlobal)
                                && tokenToMatchNumber.containsKey(counterGlobal - 1)
                                && tokenToMatchNumber.containsKey(counterGlobal + 1)) {

                            if (Objects.equals(tokenToMatchNumber.get(counterGlobal - 1),
                                    tokenToMatchNumber.get(counterGlobal + 1))) {

                                separator = SPACE;
                                lastTokenWasMatched = tokenToMatchNumber.get(counterGlobal + 1);
                            } else {

                                separator = TAB_MARK;
                                lastTokenWasMatched = -1;
                            }

                        }
                        // mark the end of a match with the tab
                        else {

                            separator = TAB_MARK;
                            lastTokenWasMatched = -1;
                        }

                    }

                    // if tok is the first token in the line and not matched, set separator to empty
                    // string
                    if (noPreviousTokenInLine && separator.equals(SPACE)) {
                        separator = "";
                    }
                    out.append(separator);

                    // append the current token
                    out.append(graph.getText(tok));
                    noPreviousTokenInLine = false;
                    prevSpeakerName = currSpeakerName;

                }

            }

        }

    }

}

From source file:com.anphat.list.controller.ListDeptAndStaffController.java

public void deptActionListener() {

    ShortcutUtils.setShortcutKey(listDepartmentsAndStaffUI.getBtnSearchDept());
    ShortcutUtils.doTextChangeUppercase(searchFormDeptController.getSearchDepartmentForm().getTxtDeptCode());
    listDepartmentsAndStaffUI.getBtnSearchDept().addClickListener(new Button.ClickListener() {

        @Override//from  ww  w .  j  a  va 2  s.c  om
        public void buttonClick(Button.ClickEvent event) {
            doSearchDepartments();
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnResetDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            doResetInputDept();
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnAddDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            DialogCreateDepartment dialogCreateDepartment = new DialogCreateDepartment(
                    BundleUtils.getString("department.management.panel.addDepartment"), new DepartmentDTO());
            dialogCreateDepartmentController = new DialogCreateDepartmentController(dialogCreateDepartment,
                    Constants.ADD, tblDepartment, tblStaff, staffForm.getF9Departments());
            dialogCreateDepartmentController.init(new DepartmentDTO());
            UI.getCurrent().addWindow(dialogCreateDepartment);
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnEditDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<DepartmentDTO> selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
            if (selectedValues != null) {
                List<DepartmentDTO> lstDepartment = Lists.newArrayList();
                for (DepartmentDTO departmentDTO : selectedValues) {
                    lstDepartment.add(departmentDTO);
                }
                if (selectedValues.size() == 1) {
                    DepartmentDTO departmentDTO;
                    departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                    DialogCreateDepartment dialogCreateContract = new DialogCreateDepartment(
                            BundleUtils.getString("department.management.panel.updateDepartment"),
                            departmentDTO);
                    dialogCreateDepartmentController = new DialogCreateDepartmentController(
                            dialogCreateContract, Constants.EDIT, tblDepartment, tblStaff,
                            staffForm.getF9Departments());
                    dialogCreateDepartmentController.init(departmentDTO);
                    UI.getCurrent().addWindow(dialogCreateContract);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnCopyDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //                DepartmentDTO selectedValues = (DepartmentDTO) tblDepartment.getValue();
            Set<DepartmentDTO> selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
            if (selectedValues != null) {
                List<DepartmentDTO> lstDepartment = Lists.newArrayList();
                for (DepartmentDTO departmentDTO : selectedValues) {
                    lstDepartment.add(departmentDTO);
                }
                if (selectedValues.size() == 1) {
                    DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                    DialogCreateDepartment dialogCreateContract = new DialogCreateDepartment(
                            BundleUtils.getString("department.management.panel.copyDepartment"), departmentDTO);
                    dialogCreateDepartmentController = new DialogCreateDepartmentController(
                            dialogCreateContract, Constants.COPY, tblDepartment, tblStaff,
                            staffForm.getF9Departments());
                    dialogCreateDepartmentController.init(departmentDTO);
                    UI.getCurrent().addWindow(dialogCreateContract);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    listDepartmentController.getBtnDel().addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();

            if (selectedValues.isEmpty()) {
                CommonUtils.showChoseOne();
            } else {
                final DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                ConfirmDialog.show(UI.getCurrent(), BundleUtils.getString("titleMessage") + "",
                        BundleUtils.getString("bodyMessage"), BundleUtils.getString("yes"),
                        BundleUtils.getString("no"), new ConfirmDialog.Listener() {
                            @Override
                            public void onClose(ConfirmDialog dialog) {
                                // tiepnv6 edit 16h 15/07/15
                                // check neu phong ban la cha thi khong xoa
                                if (deptIsParent(departmentDTO)) {
                                    Notification.show(
                                            BundleUtils.getString("dept.staff.required.delete.staff.1"),
                                            Notification.Type.HUMANIZED_MESSAGE);
                                    return;
                                }
                                //check neu bang phong ban co nhan vien thi xoa phong ban fai xoa het nv
                                if (!checkHasValue(departmentDTO)) {
                                    if (dialog.isConfirmed()) {
                                        List<DepartmentDTO> lstDeptDel = Lists.newArrayList();
                                        lstDeptDel.addAll(selectedValues);
                                        if (selectedValues.size() > 1) {
                                            //neu dept khong co dept cap con thi xoa
                                            List<DepartmentDTO> listChildOfDept = Lists.newArrayList();
                                            DepartmentDTO deptDTODel = new DepartmentDTO();
                                            deptDTODel = lstDeptDel.get(0);
                                            listChildOfDept = getChildDepartment(deptDTODel);
                                            if (listChildOfDept != null) {
                                                // Notification with default settings for a warning
                                                String showDepartmentChild = "";
                                                for (DepartmentDTO listChildOfDept1 : listChildOfDept) {
                                                    listChildOfDept1.getName();
                                                    showDepartmentChild += listChildOfDept1.getName() + ", ";
                                                }
                                                Notification notif = new Notification(
                                                        BundleUtils.getString("Warning"),
                                                        BundleUtils
                                                                .getString("message.required.deleteDepartment")
                                                                + "<br/>" + showDepartmentChild,
                                                        Notification.Type.TRAY_NOTIFICATION);
                                                notif.setDelayMsec(20000);
                                                notif.setPosition(Position.BOTTOM_RIGHT);
                                                notif.setStyleName("mystyle");
                                                notif.show(Page.getCurrent());
                                                //
                                            } else {
                                                message = doDeleteLstDept(lstDeptDel);
                                            }
                                            if (message.contains(Constants.SUCCESS)) {
                                                for (DepartmentDTO deptDTO : lstDeptDel) {
                                                    tblDepartment.removeItem(deptDTO);
                                                }
                                                tblDepartment.refreshRowCache();
                                                tblDepartment.resetPage();
                                                CommonUtils
                                                        .showDeleteSuccess(BundleUtils.getString("department"));
                                            } else {
                                                CommonUtils.showDeleteFail(BundleUtils.getString("department"));
                                            }
                                        } else {
                                            //                                                tblDepartment = listDepartmentsAndStaffUI.getTblListDepartmentUI().getMainTable();
                                            List<DepartmentDTO> listDepartment = Lists.newArrayList();
                                            selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
                                            DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues
                                                    .toArray()[0];
                                            //                                                departmentDTO.setUserNameLogging("Username");
                                            listDepartment.add(departmentDTO);
                                            message = doDeleteLstDept(listDepartment);
                                            if (message.contains(Constants.SUCCESS)) {

                                                tblDepartment.removeItem(departmentDTO);
                                                tblDepartment.resetPage();
                                                CommonUtils
                                                        .showDeleteSuccess(BundleUtils.getString("department"));
                                            } else {
                                                CommonUtils.showDeleteFail(BundleUtils.getString("department"));
                                            }
                                        }
                                    }
                                } else {
                                    Notification.show(BundleUtils.getString("dept.staff.required.delete.staff"),
                                            Notification.Type.HUMANIZED_MESSAGE);
                                }
                            }
                        });
            }
            CommonFunction.enableButtonAfterClick(event);
        }

    });
    btnAddMapStaffCusts.setDisableOnClick(true);
    btnAddMapStaffCusts.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<StaffDTO> selectedValues = (Set<StaffDTO>) tblStaff.getValue();
            if (!DataUtil.isListNullOrEmpty(Lists.newArrayList(selectedValues))) {
                MapStaffCustomerDialog dialogAddMapStaffGoods = new MapStaffCustomerDialog();
                MapStaffCustomerController mapStaffCustomerController = new MapStaffCustomerController(
                        dialogAddMapStaffGoods, Lists.newArrayList(selectedValues), lstAllAppParams);
                DataUtil.reloadWindow(dialogAddMapStaffGoods);
                UI.getCurrent().addWindow(dialogAddMapStaffGoods);
            } else {
                CommonMessages.showWarningMessage(BundleUtils.getString("notification.staff.customer.choice"));
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });
}

From source file:com.esofthead.mycollab.vaadin.ui.NotificationUtil.java

License:Open Source License

public static void showNotification(String caption, String description, Type type) {
    Notification warnNotif = new Notification(caption, description, type);
    warnNotif.setHtmlContentAllowed(true);
    warnNotif.setDelayMsec(3000);/* ww w  .j a  v a 2s .  c o m*/

    if (Page.getCurrent() != null) {
        warnNotif.show(Page.getCurrent());
    } else {
        LOG.error("Current page is null");
    }

}

From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java

License:Open Source License

private void displayTrayNotification(AbstractNotification item) {
    if (item instanceof NewUpdateAvailableNotification) {
        NewUpdateAvailableNotification updateNo = (NewUpdateAvailableNotification) item;
        Notification no;//from  w w  w  .  j  a v a  2s.  co  m
        if (AppContext.isAdmin()) {
            no = new Notification(AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    AppContext.getMessage(
                            ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion())
                            + " "
                            + new A("javascript:com.mycollab.scripts.upgrade('" + updateNo.getVersion() + "','"
                                    + updateNo.getAutoDownloadLink() + "','" + updateNo.getManualDownloadLink()
                                    + "')").appendText(AppContext.getMessage(ShellI18nEnum.ACTION_UPGRADE)),
                    Notification.Type.TRAY_NOTIFICATION);
        } else {
            no = new Notification(AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    AppContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion()),
                    Notification.Type.TRAY_NOTIFICATION);
        }

        no.setHtmlContentAllowed(true);
        no.setDelayMsec(300000);

        UI currentUI = UI.getCurrent();
        if (currentUI != null) {
            if (SiteConfiguration.getPullMethod() == SiteConfiguration.PullMethod.push) {
                no.show(currentUI.getPage());
                currentUI.push();
            } else {
                try {
                    UI.getCurrent().setPollInterval(1000);
                    no.show(currentUI.getPage());
                } finally {
                    UI.getCurrent().setPollInterval(-1);
                }
            }
        }
    }
}

From source file:com.foc.vaadin.FocWebEnvironment.java

License:Apache License

@Override
public void showNotification(String notificationMessage, String description, int notificationType, int delay,
        String styleName) {//from w  w w .  j  av  a 2  s.co  m
    try {
        if (Globals.getApp() != null && Globals.getApp().isUnitTest()
                && FocUnitDictionary.getInstance() != null) {
            FocUnitDictionary.getInstance().expectedNotification_Occured(notificationMessage, description,
                    notificationType);
        } else {
            FocWebSession focWebSession = FocWebApplication.getFocWebSession_Static();
            if (focWebSession == null || focWebSession.isNotificationEnabled()) {
                Notification.Type type = Notification.Type.ERROR_MESSAGE;
                if (notificationType == IFocEnvironment.TYPE_ERROR_MESSAGE) {
                    FocLogger.getInstance().addError("Error Popup: " + notificationMessage + " " + description);
                } else if (notificationType == IFocEnvironment.TYPE_WARNING_MESSAGE) {
                    FocLogger.getInstance()
                            .addWarning("Warning Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.WARNING_MESSAGE;
                } else if (notificationType == IFocEnvironment.TYPE_HUMANIZED_MESSAGE) {
                    FocLogger.getInstance().addInfo("Info Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.HUMANIZED_MESSAGE;
                } else if (notificationType == IFocEnvironment.TYPE_TRAY_NOTIFICATION) {
                    FocLogger.getInstance().addInfo("Tray Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.TRAY_NOTIFICATION;
                }
                Notification notification = new Notification(notificationMessage, description, type);
                notification.setDelayMsec(delay);

                if (!Utils.isStringEmpty(styleName))
                    notification.setStyleName(styleName);
                if (Page.getCurrent() != null) {
                    notification.show(Page.getCurrent());
                }
                /*
                FancyNotifications fancyNotifications = new FancyNotifications();
                fancyNotifications.setPosition(Position.BOTTOM_RIGHT);
                        
                FancyNotification fancyNotification = new FancyNotification(null, notificationMessage, description);
                fancyNotification.getTitleLabel().setContentMode(ContentMode.HTML);
                fancyNotification.getDescriptionLabel().setContentMode(ContentMode.HTML);
                fancyNotification.addLayoutClickListener(notificationClickEvent -> Page.getCurrent().setLocation("https://github.com/alump/FancyLayouts"));
                fancyNotifications.showNotification(fancyNotification);
                */
            }
        }
    } catch (Exception e) {
        Globals.logExceptionWithoutPopup(e);
    }
    //    Notification.show(notificationMessage, description, type);
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

@Override
public void showNotification(String caption, String description, NotificationType type) {
    backgroundWorker.checkUIAccess();//from www  .j a va2  s  . c o  m

    Notification notification = new Notification(caption, description, convertNotificationType(type));
    notification.setHtmlContentAllowed(NotificationType.isHTML(type));
    setNotificationDelayMsec(notification, type);
    notification.show(Page.getCurrent());
}

From source file:com.klwork.explorer.NotificationManager.java

License:Apache License

public void showWarningNotification(String captionKey, String descriptionKey, Object... params) {
    Notification notification = new Notification(i18nManager.getMessage(captionKey) + "<br/>",
            MessageFormat.format(i18nManager.getMessage(descriptionKey), params),
            Notification.Type.WARNING_MESSAGE);
    notification.setDelayMsec(5000); // click to hide
    notification.show(Page.getCurrent());
}

From source file:com.lst.deploymentautomation.vaadin.core.LspsUI.java

License:Open Source License

/**
 * Shows an error message to the user. If an exception is passed as an argument, it's message is used as the error message detail.
 * @param key//from w  w  w .  ja  v  a2  s  . c  om
 * @param e
 * @param args
 */
public void showErrorMessage(String key, Throwable e, Object... args) {
    String msg = getMessage(key, args);
    String detail = e == null ? null : e.getMessage() == null ? e.toString() : e.getMessage();
    Notification notification = new Notification(msg, detail, Notification.Type.ERROR_MESSAGE);
    notification.show(getPage());
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private void login() {
    if (accessControl.signIn(username.getValue(), password.getValue())) {
        loginListener.loginSuccessful();
    } else {/*  ww  w  .j a  v  a 2s .c o m*/
        showNotification(new Notification("Login failed",
                "Please check your username and password and try again.", Notification.Type.HUMANIZED_MESSAGE));
        username.focus();
    }
}

From source file:com.mycollab.vaadin.ui.NotificationUtil.java

License:Open Source License

public static void showNotification(String caption, String description, Type type) {
    Notification notification = new Notification(caption, description, type);
    notification.setHtmlContentAllowed(true);
    notification.setDelayMsec(3000);/*from   w ww.  ja  v  a2  s  .c  om*/

    if (Page.getCurrent() != null) {
        notification.show(Page.getCurrent());
    } else {
        LOG.error("Current page is null");
    }

}