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) 

Source Link

Document

Creates a "humanized" notification message with a bigger caption and smaller description.

Usage

From source file:de.symeda.sormas.ui.samples.PathogenTestController.java

License:Open Source License

private void showSaveNotification(CaseDataDto existingCaseDto, CaseDataDto newCaseDto) {
    if (existingCaseDto.getCaseClassification() != newCaseDto.getCaseClassification()
            && newCaseDto.getClassificationUser() == null) {
        Notification notification = new Notification(
                String.format(I18nProperties.getString(Strings.messagePathogenTestSaved),
                        newCaseDto.getCaseClassification().toString()),
                Type.WARNING_MESSAGE);
        notification.setDelayMsec(-1);/*from ww w .  j av a  2s.c o  m*/
        notification.show(Page.getCurrent());
    } else {
        Notification.show(I18nProperties.getString(Strings.messagePathogenTestSavedShort),
                Type.TRAY_NOTIFICATION);
    }
}

From source file:de.symeda.sormas.ui.statistics.StatisticsView.java

License:Open Source License

private void addGenerateButton(VerticalLayout statisticsLayout) {
    Button generateButton = new Button(I18nProperties.getCaption(Captions.actionGenerate));
    CssStyles.style(generateButton, ValoTheme.BUTTON_PRIMARY);
    generateButton.addClickListener(e -> {
        // Check whether there is any invalid empty filter or grouping data
        Notification errorNotification = null;
        for (StatisticsFilterComponent filterComponent : filterComponents) {
            if (filterComponent.getSelectedAttribute() != StatisticsCaseAttribute.REGION_DISTRICT
                    && (filterComponent.getSelectedAttribute() == null
                            || filterComponent.getSelectedAttribute().getSubAttributes().length > 0
                                    && filterComponent.getSelectedSubAttribute() == null)) {
                errorNotification = new Notification(
                        I18nProperties.getString(Strings.messageSpecifyFilterAttributes), Type.WARNING_MESSAGE);
                break;
            }/*w w w. j a v a  2 s  . c  o  m*/
        }

        if (errorNotification == null && visualizationComponent.getRowsAttribute() != null
                && visualizationComponent.getRowsAttribute().getSubAttributes().length > 0
                && visualizationComponent.getRowsSubAttribute() == null) {
            errorNotification = new Notification(I18nProperties.getString(Strings.messageSpecifyRowAttribute),
                    Type.WARNING_MESSAGE);
        } else if (errorNotification == null && visualizationComponent.getColumnsAttribute() != null
                && visualizationComponent.getColumnsAttribute().getSubAttributes().length > 0
                && visualizationComponent.getColumnsSubAttribute() == null) {
            errorNotification = new Notification(
                    I18nProperties.getString(Strings.messageSpecifyColumnAttribute), Type.WARNING_MESSAGE);
        }

        if (errorNotification != null) {
            errorNotification.setDelayMsec(-1);
            errorNotification.show(Page.getCurrent());
        } else {
            resultsLayout.removeAllComponents();
            switch (visualizationComponent.getVisualizationType()) {
            case TABLE:
                generateTable();
                break;
            case MAP:
                generateMap();
                break;
            default:
                generateChart();
                break;
            }
        }
    });

    statisticsLayout.addComponent(generateButton);
}

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

License:Open Source License

@Override
public void filterRemoved(Object propertyId) {
    Notification n = new Notification("Filter removed from: " + propertyId,
            Notification.Type.TRAY_NOTIFICATION);
    n.setDelayMsec(800);/*from w  w w . j  av a 2s.c  o m*/
    // n.show(Page.getCurrent());
}

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

License:Open Source License

@Override
public void filterAdded(Object propertyId, Class<? extends Filter> filterType, Object value) {
    Notification n = new Notification("Filter added to: " + propertyId, Notification.Type.TRAY_NOTIFICATION);
    n.setDelayMsec(800);/*from  ww w .ja  va2 s.c  om*/
    // n.show(Page.getCurrent());
}

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

License:Open Source License

public void updateUI(final ProjectBean currentBean) {
    BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler
            .computeIvacPatientStatus(currentBean);

    int finishedExperiments = 0;
    status.removeAllComponents();//from  w w  w  . j a v  a 2 s .  c om
    status.setWidth(100.0f, Unit.PERCENTAGE);

    // Generate button caption column
    final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans);
    gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() {

        @Override
        public Class<String> getType() {
            return String.class;
        }

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            String status = null;

            if ((double) item.getItemProperty("status").getValue() > 0.0) {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily()
                        + ";color:" + "#2dd085" + "\">&#x"
                        + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>";
            } else {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily()
                        + ";color:" + "#f54993" + "\">&#x"
                        + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>";
            }

            return status.toString();
        }
    });
    gpc.removeContainerProperty("identifier");

    experiments.setContainerDataSource(gpc);
    // experiments.setHeaderVisible(false);
    // experiments.setHeightMode(HeightMode.ROW);
    experiments.setHeightByRows(gpc.size());
    experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);

    experiments.getColumn("status").setRenderer(new ProgressBarRenderer());
    // experiments.setColumnOrder("started", "code", "description", "status", "download",
    // "runWorkflow");
    experiments.setColumnOrder("started", "code", "description", "status", "workflow");

    experiments.getColumn("workflow").setRenderer(new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();
            TabSheet parent = (TabSheet) getParent();
            PatientView pv = (PatientView) parent.getParent().getParent();
            WorkflowComponent wp = pv.getWorkflowComponent();

            // TODO WATCH OUT NUMBER OF WORKFLOW TAB IS HARDCODED AT THE MOMENT, NO BETTER SOLUTION
            // FOUND SO FAR, e.g. get Tab by Name ?

            // TODO idea get description of item to navigate to the correct workflow ?!
            if (esb.getDescription().equals("Barcode Generation")) {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                message.add(currentBean.getId());
                //TODO navigate to barcode dragon rawwwr
                //          message.add(BarcodeView.navigateToLabel);
                //          state.notifyObservers(message);
            } else if (esb.getDescription().equals("Variant Annotation")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_VARIANT_ANNOTATION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */

                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_VARIANT_ANNOTATION");
                parent.setSelectedTab(9);
                wp.update(args);

            } else if (esb.getDescription().equals("Epitope Prediction")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_EPITOPE_PREDICTION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_EPITOPE_PREDICTION");
                parent.setSelectedTab(9);
                wp.update(args);
            } else if (esb.getDescription().equals("HLA Typing")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_HLATYPING"); message.add(sb.toString());
                 * message.add(WorkflowView.navigateToLabel); state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_HLATYPING");
                parent.setSelectedTab(9);
                wp.update(args);
            }

            else {
                Notification notif = new Notification("Workflow not (yet) available.", Type.TRAY_NOTIFICATION);
                // Customize it
                notif.setDelayMsec(60000);
                notif.setPosition(Position.MIDDLE_CENTER);
                // Show it in the page
                notif.show(Page.getCurrent());
            }
        }
    }));

    experiments.getColumn("started").setRenderer(new HtmlRenderer());

    ProgressBar progressBar = new ProgressBar();
    progressBar.setCaption("Overall Progress");
    progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);
    progressBar.setStyleName("patientprogress");

    status.addComponent(progressBar);
    status.addComponent(experiments);
    status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER);

    /**
     * Defined Experiments for iVac - Barcodes available -> done with project creation (done) -
     * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status
     * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction
     * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION)
     */

    for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) {
        ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next();

        finishedExperiments += statusBean.getStatus();

        // statusBean.setDownload("Download");
        statusBean.setWorkflow("Run");
    }

    progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size());
}

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

License:Open Source License

void showNotification(String message) {
    Notification notif = new Notification(message, Type.TRAY_NOTIFICATION);
    // Customize it
    notif.setDelayMsec(60000);//from w w w  . j  a  v  a2 s .c  o  m
    notif.setPosition(Position.MIDDLE_CENTER);
    // Show it in the page
    notif.show(Page.getCurrent());

}

From source file:ed.cracken.pos.ui.products.ProductForm.java

public ProductForm(ProductCrudLogic crudLogic) {
    super();//w  w  w. ja  v  a2 s . c  om
    viewLogic = crudLogic;
    initComponents();
    price.setConverter(new EuroConverter());

    for (Availability s : Availability.values()) {
        availability.addItem(s);
    }

    fieldGroup = new BeanFieldGroup<>(Product.class);
    fieldGroup.bindMemberFields(this);

    // perform validation and enable/disable buttons while editing
    Property.ValueChangeListener valueListener = (Property.ValueChangeEvent event) -> {
        formHasChanged();
    };
    fieldGroup.getFields().stream().forEach((f) -> {
        f.addValueChangeListener(valueListener);
    });

    fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() {

        @Override
        public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
        }

        @Override
        public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
            DataService.get().updateProduct(fieldGroup.getItemDataSource().getBean());
        }
    });

    save.addClickListener((Button.ClickEvent event) -> {
        try {
            fieldGroup.commit();

            // only if validation succeeds
            Product product = fieldGroup.getItemDataSource().getBean();
            viewLogic.saveProduct(product);
        } catch (FieldGroup.CommitException e) {
            Notification n = new Notification("Please re-check the fields", Notification.Type.ERROR_MESSAGE);
            n.setDelayMsec(500);
            n.show(getUI().getPage());
        }
    });

    cancel.addClickListener((Button.ClickEvent event) -> {
        viewLogic.cancelProduct();
    });

    delete.addClickListener((Button.ClickEvent event) -> {
        Product product = fieldGroup.getItemDataSource().getBean();
        viewLogic.deleteProduct(product);
    });
}

From source file:ed.cracken.pos.ui.purchases.PurchaseItemForm.java

private void configBinding() {
    fieldGroup = new BeanFieldGroup<>(ItemTo.class);
    fieldGroup.bindMemberFields(this);

    Property.ValueChangeListener valueListener = (Property.ValueChangeEvent event) -> {
        formHasChanged();/*  w w  w .  j  a va 2 s .  c om*/
    };
    fieldGroup.getFields().stream().forEach((f) -> {
        f.addValueChangeListener(valueListener);
    });

    save.addClickListener((Button.ClickEvent event) -> {
        try {
            fieldGroup.commit();
            // update grid item
        } catch (FieldGroup.CommitException e) {
            Notification n = new Notification("Please re-check the fields", Notification.Type.ERROR_MESSAGE);
            n.setDelayMsec(500);
            n.show(getUI().getPage());
        }
    });

    cancel.addClickListener((Button.ClickEvent event) -> {
        // just cancel
    });

    delete.addClickListener((Button.ClickEvent event) -> {
        //remove from list
    });
}

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);//from ww  w  . ja va2s. c  o  m
    notif.setDelayMsec(-1); // user must click
    notif.show(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  w w  .  j  ava2s.  c  om*/
 * @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());
    }

}