List of usage examples for com.vaadin.ui Notification setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed)
From source file:fi.semantum.strategia.widget.Meter.java
License:Open Source License
public static void updateMeters(final Main main, boolean canWrite) { if (main.getUIState().currentItem instanceof Strategiakartta) return;//from w w w. ja va 2 s . co m final Database database = main.getDatabase(); final Base base = main.getUIState().currentItem; List<MeterDescription> descs = makeMeterDescriptions(main, base, false); if (!descs.isEmpty() || canWrite) { HorizontalLayout meterHeader = new HorizontalLayout(); meterHeader.setSpacing(true); Label header = new Label("Mittarit"); main.propertyCells.add(Utils.excelRow(header.getValue())); header.setHeight("32px"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); meterHeader.addComponent(header); meterHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER); if (canWrite) { final Image editMeters = new Image(null, new ThemeResource("chart_bar_edit.png")); editMeters.setHeight("24px"); editMeters.setWidth("24px"); editMeters.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 2661060702097338722L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.loseFocus(editMeters); manageMeters(main, main.getUIState().currentItem); } }); meterHeader.addComponent(editMeters); meterHeader.setComponentAlignment(editMeters, Alignment.BOTTOM_CENTER); } main.properties.addComponent(meterHeader); main.properties.setComponentAlignment(meterHeader, Alignment.MIDDLE_CENTER); VerticalLayout meters = new VerticalLayout(); boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI); Property time = Property.find(database, Property.AIKAVALI); int index = 0; for (final MeterDescription desc : descs) { ArrayList<String> excelRow = new ArrayList<String>(); final Meter meter = desc.meter; 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 = updateMeterValue(main, hl, base, meter, canWrite); excelRow.add(value); String shortComment = ""; Indicator indicator = meter.getPossibleIndicator(database); if (indicator != null) shortComment = indicator.getValueShortComment(); Label comment = new Label(shortComment); 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(meter); 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); } AbsoluteLayout image = new AbsoluteLayout(); image.setWidth("32px"); image.setHeight("32px"); image.addStyleName("meterColor" + index); String color = meter.getTrafficColor(database); Styles styles = Page.getCurrent().getStyles(); styles.add( ".fi_semantum_strategia div." + "meterColor" + index + " { background: " + color + "; }"); hl.addComponent(image); hl.setComponentAlignment(image, Alignment.MIDDLE_CENTER); hl.setExpandRatio(image, 0.0f); meters.addComponent(hl); meters.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); ThemeResource res = desc.meter.showInMap ? new ThemeResource("zoom.png") : new ThemeResource("zoom_out.png"); final Image show = new Image(); show.setSource(res); show.setHeight("24px"); show.setWidth("24px"); if (canWrite) { show.setDescription("Klikkaamalla voit valita, nytetnk mittaria strategiakartassa"); show.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7156984656942915939L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { desc.meter.setShowInMap(!desc.meter.showInMap); Updates.update(main, true); } }); } hl.addComponent(show); hl.setComponentAlignment(show, Alignment.MIDDLE_CENTER); final Image wiki = new Image(); wiki.setSource(new ThemeResource("table_edit.png")); wiki.setHeight("24px"); wiki.setWidth("24px"); wiki.setDescription("Klikkaamalla voit siirty tausta-asiakirjaan"); wiki.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7156984656942915939L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Wiki.openWiki(main, desc.meter); } }); hl.addComponent(wiki); hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER); if (canWrite) { final Button principalButton = new Button(); if (meter.isPrincipal) { principalButton.setCaption("Poista kokonaisarvio"); } else { principalButton.setCaption("Aseta kokonaisarvioksi"); } principalButton.setStyleName(ValoTheme.BUTTON_TINY); principalButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 8247560202892661226L; @Override public void buttonClick(ClickEvent event) { if (meter.isPrincipal) { meter.isPrincipal = false; } else { for (Meter m : base.getMeters(database)) m.isPrincipal = false; meter.isPrincipal = true; } Updates.update(main, true); } }); hl.addComponent(principalButton); hl.setComponentAlignment(principalButton, Alignment.MIDDLE_CENTER); } main.propertyCells.add(excelRow); } meters.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 MeterDescription) { MeterDescription desc = (MeterDescription) data; return desc.meter.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(meters); main.properties.setComponentAlignment(meters, Alignment.MIDDLE_CENTER); } }
From source file:org.dussan.vaadin.dcharts.test.DChartsTestUI.java
License:Apache License
private void showEventNotification(String event, Object chartObject) { String caption = "<span style='color:#ff6600'>Event: " + event + "</span>"; StringBuilder description = new StringBuilder(); if (chartObject instanceof ChartData) { ChartData chartData = (ChartData) chartObject; description.append("<b>Chart id:</b> " + chartData.getChartId()); if (chartData.getSeriesIndex() != null) { description.append("<br /><b>Series index:</b> " + chartData.getSeriesIndex()); }/* www . ja v a2s. c o m*/ if (chartData.getPointIndex() != null) { description.append("<br /><b>Point index:</b> " + chartData.getPointIndex()); } if (chartData.getData() != null) { description.append("<br /><b>Chart data:</b> " + Arrays.toString(chartData.getData())); } if (chartData.getOriginData() != null) { if (chartData.getOriginData() instanceof Object[]) { description.append( "<br /><b>Origin data:</b> " + Arrays.toString((Object[]) chartData.getOriginData())); } else { description.append("<br /><b>Origin data:</b> " + chartData.getOriginData().toString()); } } } else if (chartObject instanceof BufferedImage) { BufferedImage chartImage = (BufferedImage) chartObject; description.append("<b>Chart image width:</b> " + chartImage.getWidth() + "px"); description.append("<br /><b>Chart image height:</b> " + chartImage.getHeight() + "px"); } Notification notification = new Notification(caption, description.toString(), Type.TRAY_NOTIFICATION); notification.setDelayMsec(3000); notification.setHtmlContentAllowed(true); notification.show(Page.getCurrent()); }
From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java
License:Open Source License
private void loginAuthenticationFailedNotification() { final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title")); notification.setDescription(i18n.getMessage("notification.login.failed.description")); notification.setHtmlContentAllowed(true); notification.setStyleName("error closable"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(1_000);//from w ww. j a v a 2s . c o m notification.show(Page.getCurrent()); }
From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java
License:Open Source License
private void loginCredentialsExpiredNotification() { final Notification notification = new Notification( i18n.getMessage("notification.login.failed.credentialsexpired.title")); notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description")); notification.setDelayMsec(10_000);// w ww.j a v a 2 s . com notification.setHtmlContentAllowed(true); notification.setStyleName("error closeable"); notification.setPosition(Position.BOTTOM_CENTER); notification.show(Page.getCurrent()); }
From source file:org.eclipse.hawkbit.ui.login.LoginView.java
License:Open Source License
void loginAuthenticationFailedNotification() { final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title")); notification.setDescription(i18n.getMessage("notification.login.failed.description")); notification.setHtmlContentAllowed(true); notification.setStyleName("error closable"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(1000);//w w w . java 2 s.co m notification.show(Page.getCurrent()); }
From source file:org.eclipse.hawkbit.ui.login.LoginView.java
License:Open Source License
void loginCredentialsExpiredNotification() { final Notification notification = new Notification( i18n.getMessage("notification.login.failed.credentialsexpired.title")); notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description")); notification.setDelayMsec(10000);//from w ww .ja v a 2s. c om notification.setHtmlContentAllowed(true); notification.setStyleName("error closeable"); notification.setPosition(Position.BOTTOM_CENTER); notification.show(Page.getCurrent()); }
From source file:ru.inovus.ui.SignInUI.java
License:Apache License
private void notification() { Notification notification = new Notification("!"); notification.setDescription(//from w w w .ja va2 s. co m "<span> ?? ? <b>User</b> <b>password</b>.</span>"); notification.setHtmlContentAllowed(true); notification.setStyleName("tray dark small closable login-help"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(20000); notification.show(Page.getCurrent()); }