List of usage examples for com.vaadin.ui Notification Notification
public Notification(String caption)
From source file:by.bigvova.ui.LoginUI.java
License:Apache License
private void notification() { Notification notification = new Notification("Welcome to Dashboard Demo"); notification.setDescription(// w w w .j a v a2s. c o m "<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:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationController.java
License:Open Source License
public ReservationController(DataModel dataModel, ReservationView reservationView, Navigator navigator) { this.dataModel = dataModel; this.reservationView = reservationView; this.navigator = navigator; reservationView.getLogoutButton().addClickListener(clickEvent -> { // Logout the user / end the session VaadinSession.getCurrent().setAttribute("user", null); // Refresh this view, the navigator should redirect to login view$ navigator.navigateTo(LoginView.NAME); });/*from ww w.j av a 2s . com*/ reservationView.getRoomSelect() .addValueChangeListener(e -> roomNumber = Integer.parseInt(e.getProperty().getValue().toString())); for (int i = 1; i < dataModel.getRooms().size() + 1; i++) { reservationView.getRoomSelect().addItem(i); reservationView.getRoomSelect().setItemCaption(i, "Room " + i); } reservationView.getMakeReservationButton().addClickListener(clickEvent -> { Date begin = reservationView.getFromField().getValue(); Date end = reservationView.getToField().getValue(); SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Notification notification = new Notification(""); notification.setDelayMsec(2000); String username = String.valueOf(VaadinSession.getCurrent().getAttribute("user")); try { Customer customer = dataModel.getCustomer(username); Room room = dataModel.getRoom(roomNumber); dataModel.addReservation(customer, room, begin, end); notification.setCaption("Success"); notification.setDescription("Added reservation for: " + username + ", Room Nr.: " + roomNumber + ", From: " + df.format(begin) + " until " + df.format(end)); notification.show(Page.getCurrent()); try { createList(username); } catch (Exception e) { e.printStackTrace(); } } catch (IllegalArgumentException iae) { notification.setCaption("Error!"); notification.setDescription("Please check the entries you made for your reservation."); notification.show(Page.getCurrent()); } catch (RuntimeException re) { notification.setCaption("Error!"); notification.setDescription("Room couldn't be found.\nCurrently available rooms: " + dataModel.getRooms().stream().map(Object::toString).collect(Collectors.joining(", ")) .replaceAll("[^\\d , ][^\\@]*\\@", "")); notification.show(Page.getCurrent()); } catch (Exception e) { notification.setCaption("Error!"); notification.setDescription("There already exists a reservation for the chosen time range."); notification.show(Page.getCurrent()); } }); reservationView.getLogoutButton().addClickListener(clickEvent -> { reservationView.getFromField().clear(); reservationView.getToField().clear(); reservationView.getRoomSelect().clear(); }); }
From source file:ch.bfh.ti.soed.hs16.srs.black.view.signUpView.SignUpController.java
License:Open Source License
public void addUser(Button.ClickEvent event) { String username = signUpView.getUsernameField().getValue(); String password = signUpView.getPasswordField().getValue(); String passwordRepeat = signUpView.getPasswordFieldRepeat().getValue(); Notification alertNf = new Notification(""); alertNf.setDelayMsec(2000);/*from w ww. j a v a2 s . co m*/ if (username.isEmpty() || password.isEmpty() || passwordRepeat.isEmpty()) { alertNf.setCaption("Please fill out the complete form!"); alertNf.show(Page.getCurrent()); } else if (!password.equals(passwordRepeat)) { alertNf.setCaption("The given passwords aren't identical!"); alertNf.show(Page.getCurrent()); signUpView.getPasswordFieldRepeat().clear(); signUpView.getPasswordFieldRepeat().focus(); } else { try { dataModel.addCustomer(username, password); navigator.navigateTo(ReservationView.NAME); alertNf.setCaption("Account: " + username + " has been successfully created."); alertNf.setDescription("You can now login with your credentials."); alertNf.show(Page.getCurrent()); } catch (IllegalStateException e) { alertNf.setCaption("User already exists!"); alertNf.setDescription("Please enter a different username."); alertNf.show(Page.getCurrent()); signUpView.getUsernameField().focus(); } finally { signUpView.getUsernameField().clear(); signUpView.getPasswordField().clear(); signUpView.getPasswordFieldRepeat().clear(); } } }
From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java
License:Apache License
Panel notifications() {
Panel p = new Panel("Notifications");
VerticalLayout content = new VerticalLayout() {
Notification notification = new Notification("");
TextField title = new TextField("Title");
TextArea description = new TextArea("Description");
MenuBar style = new MenuBar();
MenuBar type = new MenuBar();
String typeString = "";
String styleString = "";
TextField delay = new TextField();
{//w w w . j a va 2 s .c o m
setSpacing(true);
setMargin(true);
title.setInputPrompt("Title for the notification");
title.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final ValueChangeEvent event) {
if (title.getValue() == null || title.getValue().length() == 0) {
notification.setCaption(null);
} else {
notification.setCaption(title.getValue());
}
}
});
title.setValue("Notification Title");
title.setWidth("100%");
addComponent(title);
description.setInputPrompt("Description for the notification");
description.addStyleName("small");
description.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final ValueChangeEvent event) {
if (description.getValue() == null || description.getValue().length() == 0) {
notification.setDescription(null);
} else {
notification.setDescription(description.getValue());
}
}
});
description.setValue(
"A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
description.setWidth("100%");
addComponent(description);
Command typeCommand = new Command() {
@Override
public void menuSelected(final MenuItem selectedItem) {
if (selectedItem.getText().equals("Humanized")) {
typeString = "";
notification.setStyleName(styleString.trim());
} else {
typeString = selectedItem.getText().toLowerCase();
notification.setStyleName((typeString + " " + styleString.trim()).trim());
}
for (MenuItem item : type.getItems()) {
item.setChecked(false);
}
selectedItem.setChecked(true);
}
};
type.setCaption("Type");
MenuItem humanized = type.addItem("Humanized", typeCommand);
humanized.setCheckable(true);
humanized.setChecked(true);
type.addItem("Tray", typeCommand).setCheckable(true);
type.addItem("Warning", typeCommand).setCheckable(true);
type.addItem("Error", typeCommand).setCheckable(true);
type.addItem("System", typeCommand).setCheckable(true);
addComponent(type);
type.addStyleName("small");
Command styleCommand = new Command() {
@Override
public void menuSelected(final MenuItem selectedItem) {
styleString = "";
for (MenuItem item : style.getItems()) {
if (item.isChecked()) {
styleString += " " + item.getText().toLowerCase();
}
}
if (styleString.trim().length() > 0) {
notification.setStyleName((typeString + " " + styleString.trim()).trim());
} else if (typeString.length() > 0) {
notification.setStyleName(typeString.trim());
} else {
notification.setStyleName(null);
}
}
};
style.setCaption("Additional style");
style.addItem("Dark", styleCommand).setCheckable(true);
style.addItem("Success", styleCommand).setCheckable(true);
style.addItem("Failure", styleCommand).setCheckable(true);
style.addItem("Bar", styleCommand).setCheckable(true);
style.addItem("Small", styleCommand).setCheckable(true);
style.addItem("Closable", styleCommand).setCheckable(true);
addComponent(style);
style.addStyleName("small");
CssLayout group = new CssLayout();
group.setCaption("Fade delay");
group.addStyleName("v-component-group");
addComponent(group);
delay.setInputPrompt("Infinite");
delay.addStyleName("align-right");
delay.addStyleName("small");
delay.setWidth("7em");
delay.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final ValueChangeEvent event) {
try {
notification.setDelayMsec(Integer.parseInt(delay.getValue()));
} catch (Exception e) {
notification.setDelayMsec(-1);
delay.setValue("");
}
}
});
delay.setValue("1000");
group.addComponent(delay);
Button clear = new Button(null, new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
delay.setValue("");
}
});
clear.setIcon(FontAwesome.TIMES_CIRCLE);
clear.addStyleName("last");
clear.addStyleName("small");
clear.addStyleName("icon-only");
group.addComponent(clear);
group.addComponent(new Label(" msec", ContentMode.HTML));
GridLayout grid = new GridLayout(3, 3);
grid.setCaption("Show in position");
addComponent(grid);
grid.setSpacing(true);
Button pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.TOP_LEFT);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.TOP_CENTER);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.TOP_RIGHT);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.MIDDLE_LEFT);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.MIDDLE_CENTER);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.MIDDLE_RIGHT);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.BOTTOM_LEFT);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.BOTTOM_CENTER);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
pos = new Button("", new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
notification.setPosition(Position.BOTTOM_RIGHT);
notification.show(Page.getCurrent());
}
});
pos.addStyleName("small");
grid.addComponent(pos);
}
};
p.setContent(content);
return p;
}
From source file:com.cms.component.CommonFunction.java
public static void showMessage(String message) { Notification noti = new Notification(message); noti.setDelayMsec(1500);// w ww . j a v a 2s.com Notification.show(message); }
From source file:com.cms.component.CommonFunction.java
public static void showError(String message) { Notification noti = new Notification(message); noti.setDelayMsec(1500);// w w w . ja v a 2 s .co m Notification.show(message, Notification.Type.ERROR_MESSAGE); }
From source file:com.cms.component.CommonFunctionTableFilter.java
public static void showMessage(String message) { Notification noti = new Notification(message); noti.setDelayMsec(1500);/* w ww .j a v a 2 s . c o m*/ noti.show(message); }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java
License:Apache License
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();//from w ww. ja v a 2 s . co m loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription("Write anything"); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); buttons.addComponent(login = new Button("Login")); login.setDisableOnClick(true); login.addClickListener(new Button.ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { try { login(); } finally { login.setEnabled(true); } } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Try anything")); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }
From source file:com.vaadHL.utl.msgs.Msgs.java
License:Apache License
public void showInfo(String caption, int delay) { Notification not = new Notification(caption); not.setDelayMsec(delay);//w w w. j a v a 2s . com not.setHtmlContentAllowed(true); not.show(Page.getCurrent()); }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java
public LoginView() { System.out.println("LOAD LLOGIN"); setSizeFull();//from w w w . j a v a 2 s .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()); }