Example usage for com.vaadin.ui Notification setHtmlContentAllowed

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

Introduction

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

Prototype

public void setHtmlContentAllowed(boolean htmlContentAllowed) 

Source Link

Document

Sets whether html is allowed in the caption and description.

Usage

From source file:com.vaadHL.utl.msgs.Msgs.java

License:Apache License

public void showError(String caption, int delay) {
    Notification not = new Notification("", Notification.Type.ERROR_MESSAGE);
    not.setDelayMsec(delay);/*from  w  ww  .j a  va2  s.c o m*/
    not.setHtmlContentAllowed(true);
    not.setCaption(caption);
    not.show(Page.getCurrent());

}

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java

public LoginView() {
    System.out.println("LOAD LLOGIN");
    setSizeFull();//from www  .j a  v  a 2s  .c om
    Component loginForm = buildLoginForm();
    addComponent(loginForm);
    setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);

    Notification notification = new Notification("Welcome to Dashboard Demo");
    notification.setDescription(
            "<span>This application is not real, it only demonstrates an application built with the <a href=\"https://vaadin.com\">Vaadin framework</a>.</span> <span>No username or password is required, just click the <b>Sign In</b> button to continue.</span>");
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("tray dark small closable login-help");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(20000);
    notification.show(Page.getCurrent());
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.MSHBiologicalSampleStateMachine.java

License:Open Source License

public boolean traverseToNextState(String sampleID) {
    // first, check if all conditions are met before traversing into next state
    String fromState = new String(currentState.name());
    String toState = new String(currentState.nextState().name());

    if (fromState.equals(toState)) {
        // nothing to do... however, we should notify the user

        Notification errorEndStateReached = new Notification(
                "The current process seems to have reached it's end state.",
                "<i>Skipping this transition with no changes performed...</i>", Type.WARNING_MESSAGE, true);

        errorEndStateReached.setHtmlContentAllowed(true);
        errorEndStateReached.show(Page.getCurrent());

        return false;
    }//from  w w w .j av a  2 s.c om

    if (currentState.checkConditions()) {

        stateMachineLogging.debug("traversing from " + fromState + " to " + toState);

        // first check if OpenBIS is still in the currentState
        String mostRecentStateName = retrieveCurrentStateFromOpenBIS();

        if (mostRecentStateName != null && !fromState.equals(mostRecentStateName)) {
            sampleViewRef.updateContent();

            Notification errorStateMoved = new Notification("The sample's status has changed in the meantime!",
                    "<i>Most likely, someone else in your group is working on the same data.</i>",
                    Type.ERROR_MESSAGE, true);

            errorStateMoved.setHtmlContentAllowed(true);
            errorStateMoved.show(Page.getCurrent());
            // this should redraw the current state

            //this.setState(mostRecentStateName);
            //this.buildCurrentInterface();

            return false;
        }

        updateOpenBISCurrentProcessState(sampleID, toState);
        sampleViewRef.updateContent();

        notifyUsersOfTransition(fromState, toState);

        return true;
    }

    return false;
}

From source file:edu.kit.dama.ui.admin.utils.UIComponentTools.java

License:Apache License

/**
 * Show a notification with caption <i>caption</i>, message <i>message</i>
 * of type <i>pType</i> for//from www .j av a 2 s  .c o  m
 * <i>delay</i> at top_center position.
 *
 * @param caption The caption.
 * @param message The message.
 * @param delay The delay (ms) until the nofication disappears.
 * @param pType The notification type.
 * @param pPosition The notification position.
 */
private static void showNotification(String caption, String message, int delay, Notification.Type pType,
        Position position) {
    Notification notification = new Notification(caption, message, pType);
    notification.setPosition(position);
    notification.setDelayMsec(delay);
    notification.setHtmlContentAllowed(true);
    notification.show(Page.getCurrent());
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

private void showNotifInAllBrowserWindows(String content, String title, String style) {
    StringBuilder sb = new StringBuilder();
    sb.append("<br/>");
    sb.append(content);//from  w w  w .j a va2 s  .  c  o  m
    filterContent(sb);
    sb.append("<br/><span style='font-size:x-small'>Click to close.</span>");
    Notification notif = new Notification(title, sb.toString(), Notification.Type.ERROR_MESSAGE);
    notif.setHtmlContentAllowed(true);
    notif.setPosition(Position.MIDDLE_CENTER);
    notif.setStyleName(style);

    iterateUIs(notif, new UIHandler() {
        public boolean handle(Mmowgli2UI ui, Object notif) {
            ((Notification) notif).show(ui.getPage());
            return true;
        }
    });
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

public void handleAboutMmowgli(MenuBar menubar) {
    Notification notif = new Notification("<center><span style='color:#777'>Mmowgli</span></center>",
            "<center>Build " + MMOWGLI_BUILD_ID + "<br/>Vaadin " + VAADIN_BUILD_VERSION
                    + "<br/><br/><span style='color:#777;font-size:70%'>Click to close</span></center>");
    notif.setHtmlContentAllowed(true);
    notif.setDelayMsec(-1); // user must click
    notif.show(Page.getCurrent());//w  w  w . j a  v a 2  s  . c  o m
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper2.java

License:Open Source License

private void showNotification(String content, String title, String style) {
    StringBuilder sb = new StringBuilder();
    sb.append("<br/>");
    sb.append(content);/*from ww w  .j  a v  a 2s . com*/
    // filterContent(sb);
    sb.append("<br/><span style='font-size:x-small'>Click to close.</span>");
    Notification notif = new Notification(title, sb.toString(), Notification.Type.ERROR_MESSAGE);
    notif.setHtmlContentAllowed(true);
    notif.setPosition(Position.MIDDLE_CENTER);
    notif.setStyleName(style);

    notif.show(myUI.getPage());
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java

License:Open Source License

private void doCACNotif(String title, String text) {
    Notification notif = new Notification(title, text, Notification.Type.HUMANIZED_MESSAGE);
    notif.setPosition(Position.BOTTOM_CENTER);
    notif.setHtmlContentAllowed(true);
    notif.setDelayMsec(2000);/*from   w  ww . j  a  va2 s  .  com*/
    notif.show(Page.getCurrent());
}

From source file:edu.nps.moves.mmowgli.signupServer.SignupServer.java

License:Open Source License

private void doRedirNotification(final String url) {
    Notification notif = new Notification("<center>Welcome to MMOWGLI!<center>",
            "<br/><center>We're taking you directly to the game.<center>", Notification.Type.HUMANIZED_MESSAGE);

    notif.setDelayMsec(5000);//from ww  w  .  j av a2  s . c om
    notif.setPosition(Position.MIDDLE_CENTER);
    notif.setHtmlContentAllowed(true);
    notif.setStyleName("m-green-notification");
    notif.show(Page.getCurrent());

    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            UI.getCurrent().access(new Runnable() {
                @Override
                public void run() {
                    quitUIAndGoTo(url);
                }
            });
        }
    }, 4000);
}

From source file:fi.semantum.strategia.widget.Indicator.java

License:Open Source License

public static void updateIndicators(final Main main, final Base base, boolean canWrite) {

    final Database database = main.getDatabase();

    List<IndicatorDescription> descs = new ArrayList<IndicatorDescription>();
    fillIndicatorDescriptions(main, base, "", descs);

    boolean isMap = base instanceof Strategiakartta;

    if (isMap && (!descs.isEmpty() || canWrite)) {

        HorizontalLayout indiHeader = new HorizontalLayout();
        indiHeader.setSpacing(true);//from www.  ja va 2  s.  com

        Label header = new Label("Indikaattorit (ennuste)");
        main.propertyCells.add(Utils.excelRow(header.getValue()));
        header.setHeight("32px");
        header.addStyleName(ValoTheme.LABEL_HUGE);
        header.addStyleName(ValoTheme.LABEL_BOLD);
        indiHeader.addComponent(header);
        indiHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER);

        if (canWrite) {

            final Image editIndicators = new Image(null, new ThemeResource("chart_line_edit.png"));
            editIndicators.setHeight("24px");
            editIndicators.setWidth("24px");
            editIndicators.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editIndicators);
                    manageIndicators(main, main.getUIState().currentItem);
                }

            });

            indiHeader.addComponent(editIndicators);
            indiHeader.setComponentAlignment(editIndicators, Alignment.BOTTOM_CENTER);

        }

        main.properties.addComponent(indiHeader);
        main.properties.setComponentAlignment(indiHeader, Alignment.MIDDLE_CENTER);

        VerticalLayout indicators = new VerticalLayout();

        boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI);

        Property time = Property.find(database, Property.AIKAVALI);

        int index = 0;
        for (final IndicatorDescription desc : descs) {

            ArrayList<String> excelRow = new ArrayList<String>();

            Indicator indicator = desc.indicator;

            final HorizontalLayout hl = new HorizontalLayout();
            hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty");
            hl.setSpacing(true);

            Label l = new Label(desc.caption);
            excelRow.add(l.getValue().replace("%nbsp", ""));
            l.setContentMode(ContentMode.HTML);
            l.setWidth("450px");
            l.addStyleName("propertyName");
            l.setData(desc);
            hl.addComponent(l);
            hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);

            String value = updateIndicatorValue(main, hl, base, indicator, canWrite);
            excelRow.add(value);

            Label unit = new Label(indicator.getUnit());
            unit.setWidth("100px");
            hl.addComponent(unit);
            hl.setComponentAlignment(unit, Alignment.MIDDLE_LEFT);
            excelRow.add(unit.getValue());

            Label comment = new Label(indicator.getValueShortComment());
            comment.setWidth("150px");
            hl.addComponent(comment);
            hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT);
            excelRow.add(comment.getValue());

            if (showYears) {

                HorizontalLayout hl2 = new HorizontalLayout();
                hl2.setWidth("70px");
                hl2.setHeight("100%");
                hl.addComponent(hl2);
                hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT);

                String years = time.getPropertyValue(indicator);
                if (years == null)
                    years = Property.AIKAVALI_KAIKKI;

                final Label region = new Label(years);
                region.setWidthUndefined();

                excelRow.add(region.getValue());

                hl2.addComponent(region);
                hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER);

            }

            final Image wiki = new Image();
            wiki.setSource(new ThemeResource("table_edit.png"));
            wiki.setHeight("24px");
            wiki.setWidth("24px");
            wiki.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Wiki.openWiki(main, desc.indicator);
                }

            });

            hl.addComponent(wiki);
            hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER);

            indicators.addComponent(hl);
            indicators.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

            main.propertyCells.add(excelRow);

        }

        indicators.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 3295743025581923380L;

            private String extractData(Component c) {
                if (c instanceof AbstractComponent) {
                    Object data = ((AbstractComponent) c).getData();
                    if (data instanceof IndicatorDescription) {
                        IndicatorDescription desc = (IndicatorDescription) data;
                        return desc.indicator.getDescription(database);
                    }
                }
                return null;
            }

            @Override
            public void layoutClick(LayoutClickEvent event) {

                String desc = extractData(event.getClickedComponent());
                if (desc == null)
                    return;

                String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">";
                content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">"
                        + desc + "</div>";
                content += "</div>";

                Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE);
                n.setHtmlContentAllowed(true);
                n.show(Page.getCurrent());

            }

        });

        main.properties.addComponent(indicators);
        main.properties.setComponentAlignment(indicators, Alignment.MIDDLE_CENTER);

    }

}