List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:edu.vserver.exercises.videoMcq.QuestionWindow.java
License:Apache License
/** * Sets a Notification about the correctness of the given answer to the browser window. * /*from w ww .ja v a 2 s.c o m*/ * @param question latest answered question. */ private void informUser(Question question) { if (this.isInformative()) { Notification n; if (question.isCorrectAnswer()) { n = new Notification("CORRECT", Notification.Type.HUMANIZED_MESSAGE); n.setIcon(new ThemeResource(SPH_Theme.CORRECT_ICON_48PX)); n.setStyleName("correctAnswer"); } else { n = new Notification("INCORRECT", Notification.Type.HUMANIZED_MESSAGE); n.setIcon(new ThemeResource(SPH_Theme.INCORRECT_ICON_48PX)); n.setStyleName("incorrectAnswer"); } if (question.containsAnswerDescription()) { n.setDescription(question.getAnswerDescription()); n.setDelayMsec(Notification.DELAY_FOREVER); } else { n.setDelayMsec(500); } n.setPosition(com.vaadin.shared.Position.MIDDLE_CENTER); n.show(Page.getCurrent()); } }
From source file:eu.eco2clouds.portal.component.apwizard.APText.java
License:Apache License
@Override public void buttonClick(ClickEvent event) { try {/*from ww w . j a va 2s . c o m*/ ApplicationProfileParserManager parser = new ApplicationProfileParserManager(); //layout.addComponent(new Label("As soon as it is ready, we will send the application profile to the scheduler. Please be patient")); System.out.println("I submit \n" + this.textArea.getValue()); ApplicationProfile applicationProfileObj = parser.parse(this.textArea.getValue()); Logger.getLogger(E2CPortal.class.getName()).log(Level.FINER, this.textArea.getValue()); SchedulerManager sm = SchedulerManagerFactory.getInstance(); sm.submitApplicationProfile(applicationProfileObj); Notification okNotification = new Notification("Success", "<br/>Application Profile has been correctly <br/>sent to the Scheduler", Notification.Type.HUMANIZED_MESSAGE, true); okNotification.show(Page.getCurrent()); } catch (JsonMappingException ex) { Notification errorNotification = new Notification("Error", "<br/>Application Profile is not valid", Notification.Type.ERROR_MESSAGE, true); errorNotification.show(Page.getCurrent()); Logger.getLogger(E2CPortal.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Notification errorNotification = new Notification("Error", "<br/>Application Profile is not valid", Notification.Type.ERROR_MESSAGE, true); errorNotification.show(Page.getCurrent()); Logger.getLogger(E2CPortal.class.getName()).log(Level.SEVERE, null, ex); } catch (E2CPortalException ex) { Notification errorNotification = new Notification("Error", "<br/>Problems while communicating with the Scheduler", Notification.Type.ERROR_MESSAGE, true); errorNotification.show(Page.getCurrent()); Logger.getLogger(E2CPortal.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:eu.eco2clouds.portal.component.NotificationTable.java
License:Apache License
private void render() { this.setWidth("100%"); this.setSizeFull(); this.setImmediate(true); this.setSelectable(true); BeanItemContainer<Notification> container = new BeanItemContainer<Notification>(Notification.class); this.setContainerDataSource(container); this.setVisibleColumns(new Object[] { "timestamp", "level", "title", "description", "source" }); this.setColumnExpandRatio("timestamp", 1.0f); this.setColumnExpandRatio("level", 1.0f); this.setColumnExpandRatio("title", 2.0f); this.setColumnExpandRatio("description", 6.0f); this.setColumnExpandRatio("source", 2.0f); this.addValueChangeListener(new Property.ValueChangeListener() { @Override// w ww . j av a 2 s. c o m public void valueChange(final Property.ValueChangeEvent event) { Notification n = (Notification) getValue(); if (n != null) { new com.vaadin.ui.Notification(n.getTitle(), "Recevied at <b>" + sdf.format(n.getTimestamp()).toString() + "</b><br/> from <b>" + n.getSource() + "</b><br/>" + n.getDescription(), com.vaadin.ui.Notification.Type.WARNING_MESSAGE, true).show(Page.getCurrent()); } } }); }
From source file:eu.eco2clouds.portal.component.NotificationTable.java
License:Apache License
public void updateNotification() { int i = 0;/*from w ww .j a v a2 s . co m*/ NotificationList nl = NotificationListFactory.getInstance(); BeanItemContainer<Notification> container = (BeanItemContainer<Notification>) this.getContainerDataSource(); int existing = container.size(); container.removeAllItems(); LinkedList<eu.eco2clouds.portal.service.data.Notification> notifications = nl.getList(); for (Notification n : notifications) { container.addBean(n); if (i >= existing) { com.vaadin.ui.Notification not = new com.vaadin.ui.Notification(n.getTitle(), n.getDescription(), com.vaadin.ui.Notification.Type.TRAY_NOTIFICATION); not.setDelayMsec(2000); not.setPosition(Position.TOP_RIGHT); not.show(Page.getCurrent()); } i++; } this.setContainerDataSource(container); }
From source file:eu.eco2clouds.portal.page.HomeLayout.java
License:Apache License
public HomeLayout() { super();/*from w w w . ja v a 2 s.com*/ String loggedUser = ((E2CPortal) UI.getCurrent()).getSessionStatus().getLoggedUser(); String loggedGroup = ((E2CPortal) UI.getCurrent()).getSessionStatus().getLoggedGroup(); BeanItemContainer<ExperimentTableBean> userActiveContainer = new BeanItemContainer<ExperimentTableBean>( ExperimentTableBean.class); BeanItemContainer<ExperimentTableBean> groupActiveContainer = new BeanItemContainer<ExperimentTableBean>( ExperimentTableBean.class); BeanItemContainer<ExperimentTableBean> terminatedContainer = new BeanItemContainer<ExperimentTableBean>( ExperimentTableBean.class); SchedulerManager scheduler; Collection<Experiment> experiments = null; try { scheduler = new SchedulerManager(Configuration.schedulerUrl, Configuration.keystoreFilename, Configuration.keystorePwd); experiments = scheduler.getExperiments(); } catch (Exception ex) { Logger.getLogger(ExperimentTable.class.getName()).log(Level.SEVERE, null, ex); new Notification("Error", "A problem occurred while connecting to the Eco2Clouds scheduler", Notification.Type.ERROR_MESSAGE, true).show(Page.getCurrent()); } //System.out.println("xx" + loggedGroup + " " + loggedUser); if (experiments != null) { for (Experiment e : experiments) { //System.out.println(e.getHref() + " " + e.getBonfireGroupId() + " " + e.getBonfireUserId() + " " + e.getStatus()); if (e.getStatus() != null) { if (!e.getStatus().equalsIgnoreCase("terminated") && e.getBonfireUserId().equals(loggedUser)) { userActiveContainer.addBean(new ExperimentTableBean(e)); } else if (!e.getStatus().equalsIgnoreCase("terminated") && e.getBonfireGroupId().equals(loggedGroup)) { groupActiveContainer.addBean(new ExperimentTableBean(e)); } else if (e.getStatus().equalsIgnoreCase("terminated")) { terminatedContainer.addBean(new ExperimentTableBean(e)); } } else { Logger.getLogger(HomeLayout.class.getName()).log(Level.INFO, "experiment " + e.getId() + " with status null"); } } } this.userActiveExperimentTable = new ExperimentTable(userActiveContainer); this.groupActiveExperimentTable = new ExperimentTable(groupActiveContainer); this.terminatedExperimentTable = new ExperimentTable(terminatedContainer); this.render(); }
From source file:eu.maxschuster.vaadin.autocompletetextfield.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { setContent(l);//from w w w . j a v a2 s .com final AutocompleteTextField languageField = l.languageField.withSuggestionProvider(languageProvider) .withMinChars(1).withSuggestionLimit(5).withTextChangeListener(this::onAutocompleteTextChange) .withValueChangeListener(this::onAutocompleteValueChange); l.scrollBehavior.setContainerDataSource( new BeanItemContainer<>(ScrollBehavior.class, Arrays.asList(ScrollBehavior.values()))); l.theme.addItems(Arrays.asList(Themes.values())); l.theme.setValue(Themes.VALO); l.theme.addValueChangeListener(this::onThemeValueChange); l.addIcon.addItems(Arrays.asList(Icons.values())); l.addIcon.setValue(Icons.NONE); l.visible.setValue(true); l.visible.addValueChangeListener(e -> { languageField.setVisible((boolean) e.getProperty().getValue()); }); l.enabled.setValue(true); l.enabled.addValueChangeListener(e -> { languageField.setEnabled((boolean) e.getProperty().getValue()); }); optionsGroup.setItemDataSource(languageField); optionsGroup.bind(l.delay, "delay"); optionsGroup.bind(l.minChars, "minChars"); optionsGroup.bind(l.suggestionLimit, "suggestionLimit"); optionsGroup.bind(l.inputPrompt, "inputPrompt"); optionsGroup.bind(l.scrollBehavior, "scrollBehavior"); optionsGroup.bind(l.cache, "cache"); l.apply.addClickListener(e -> { try { optionsGroup.commit(); } catch (FieldGroup.CommitException ex) { getLogger().log(Level.SEVERE, null, ex); Notification notification = new Notification("Error applying changes!", Notification.Type.ERROR_MESSAGE); notification.setDelayMsec(2000); notification.show(Page.getCurrent()); } }); l.reset.addClickListener(e -> reset()); optionsGroup.addCommitHandler(new FieldGroup.CommitHandler() { @Override public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException { } @Override public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException { Notification.show("Options applied!"); } }); l.windowTest.addClickListener(e -> openTestWindow()); l.demoOverlayTest.setSuggestionProvider(languageProvider); }
From source file:eu.maxschuster.vaadin.autocompletetextfield.demo.DemoUI.java
License:Apache License
private void onAutocompleteValueChange(Property.ValueChangeEvent event) { String text = "Value changed to: " + event.getProperty().getValue(); Notification notification = new Notification(text, Notification.Type.TRAY_NOTIFICATION); notification.setPosition(Position.BOTTOM_LEFT); notification.show(Page.getCurrent()); }
From source file:facs.components.BookAdmin.java
License:Open Source License
private void showErrorNotification(String title, String description) { Notification notify = new Notification(title, description); notify.setDelayMsec(15000);//from ww w .ja v a2 s . c om notify.setPosition(Position.TOP_CENTER); notify.setIcon(FontAwesome.FROWN_O); notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE); notify.show(Page.getCurrent()); }
From source file:facs.components.BookAdmin.java
License:Open Source License
private void Notification(String title, String description, String type) { Notification notify = new Notification(title, description); notify.setPosition(Position.TOP_CENTER); if (type.equals("error")) { notify.setDelayMsec(16000);/*www .j av a 2 s.c o m*/ notify.setIcon(FontAwesome.FROWN_O); notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE); } else if (type.equals("success")) { notify.setDelayMsec(8000); notify.setIcon(FontAwesome.SMILE_O); notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE); } else { notify.setDelayMsec(8000); notify.setIcon(FontAwesome.MEH_O); notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE); } notify.show(Page.getCurrent()); }
From source file:facs.components.Booking.java
License:Open Source License
private void showErrorNotification(String title, String description) { Notification notify = new Notification(title, description); notify.setDelayMsec(16000);//from w w w . ja v a 2s .co m notify.setPosition(Position.TOP_CENTER); notify.setIcon(FontAwesome.FROWN_O); notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE); notify.show(Page.getCurrent()); }