Example usage for com.vaadin.ui Notification show

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

Introduction

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

Prototype

public static Notification show(String caption, String description, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:com.klwork.explorer.NotificationManager.java

License:Apache License

public void showErrorNotification(String captionKey, Exception exception) {
    Notification.show(i18nManager.getMessage(captionKey), "<br/>" + exception.getMessage(),
            Notification.Type.ERROR_MESSAGE);
}

From source file:com.klwork.explorer.NotificationManager.java

License:Apache License

public void showWarningNotification(String captionKey, String descriptionKey) {
    /* Notification notification = new Notification(i18nManager.getMessage(captionKey), 
    i18nManager.getMessage(descriptionKey), 
    Notification.Type.WARNING_MESSAGE);/*from  ww  w.  j a  v  a2  s  .  c om*/
     notification.setDelayMsec(-1); // click to hide
    */ //notification.show(page)
    Notification.show(i18nManager.getMessage(captionKey), i18nManager.getMessage(descriptionKey),
            Notification.Type.WARNING_MESSAGE);

}

From source file:com.mycompany.project.components.ContactDetails.java

public ContactDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//w  w w  .j  av a2  s  . c  om
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    tfName.setSizeFull();
    tfAddress.setSizeFull();
    tfPhone.setSizeFull();
    tfEmail.setSizeFull();

    Panel panel = new Panel("Grupos");
    panel.setWidth("100%");
    panel.setHeight("50px");
    panel.setContent(groupsHLayout);

    mainVLayout.addComponent(tfName);
    mainVLayout.addComponent(tfAddress);
    mainVLayout.addComponent(tfPhone);
    mainVLayout.addComponent(tfEmail);
    mainVLayout.addComponent(groupsHLayout);

    Button btnUpdate = new Button("Actualizar");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();
            String address = tfAddress.getValue();
            String phone = tfPhone.getValue();
            String email = tfEmail.getValue();

            ArrayList<String> selectedGroupIds = new ArrayList<String>();
            Set<String> groupIdSet = groupsMap.keySet();
            for (String groupId : groupIdSet) {
                CheckBox cb = groupsMap.get(groupId);
                if (cb.getValue()) {
                    selectedGroupIds.add(groupId);
                }
            }

            boolean success = bl.updateContact(selectedContactId, name, address, phone, email,
                    selectedGroupIds);
            if (success) {
                load(selectedContactId);
                Notification.show("Informacion", "Contacto Actualizado", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    ContactDetails.this.setVisible(false);
}

From source file:com.mycompany.project.components.ContactDetails.java

private void load(String contactId) {
    // get hold of the business logic

    BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();
    Contact contact = bl.getContact(contactId);
    if (contact != null) {
        tfName.setValue(contact.getName());
        tfAddress.setValue(contact.getAddress());
        tfPhone.setValue(contact.getPhone());
        tfEmail.setValue(contact.getEmail());

        loadAllGroups();/*from   w w w.ja va2 s.  c  o  m*/
        //set groups
        for (int i = 0; i < contact.getGroupIds().size(); i++) {
            CheckBox cb = groupsMap.get(contact.getGroupIds().get(i));
            cb.setValue(true);
        }
    } else {
        ContactDetails.this.setVisible(false);
        Notification.show("Error", "\nContact could not be loaded", Notification.Type.ERROR_MESSAGE);
    }
}

From source file:com.mycompany.project.components.GroupDetails.java

public GroupDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);/*from   w ww  .  j a v a2s . com*/
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);
    tfName.setSizeFull();
    mainVLayout.addComponent(tfName);

    Button btnUpdate = new Button("Update");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();

            boolean success = bl.updateGroup(selectedGroupId, name);
            if (success) {
                load(selectedGroupId);
                Notification.show("Success", "Group updated", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    GroupDetails.this.setVisible(false);
}

From source file:com.mycompany.project.components.GroupDetails.java

private void load(String groupId) {
    // get hold of the business logic
    BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();
    Group group = bl.getGroup(groupId);
    if (group != null) {
        tfName.setValue(group.getName());
    } else {/*w ww.  j  a va 2 s.  co m*/
        GroupDetails.this.setVisible(false);
        Notification.show("Error", "\nGroup could not be loaded", Notification.Type.ERROR_MESSAGE);
    }
}

From source file:com.mycompany.project.components.NewContactForm.java

public NewContactForm() {

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);/*from ww w.  jav a2 s.co  m*/
    mainVLayout.setSpacing(true);
    mainVLayout.addStyleName(boostrap.Forms.FORM.styleName());
    setContent(mainVLayout);

    // field properties
    tfName.setSizeFull();
    tfPhone.setSizeFull();
    tfemail.setSizeFull();

    tfName.focus();

    mainVLayout.addComponent(tfName);
    mainVLayout.addComponent(tfPhone);
    mainVLayout.addComponent(tfemail);

    Button btnSave = new Button("Guardar");
    mainVLayout.addComponent(btnSave);

    btnSave.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            // get hold of the business logic

            String name = tfName.getValue();
            String phone = tfPhone.getValue();
            String email = tfemail.getValue();

            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();
            String newContactId = bl.saveNewContact(name, phone, email);

            if (newContactId != null) {
                //saved successfully
                Notification.show("Success", name + " saved", Notification.Type.TRAY_NOTIFICATION);
                //reset fields
                resetFields();
            } else {
                //something bad happened
                Notification.show("Error", "\nContact could not be saved", Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.mycompany.project.components.NewGroupForm.java

public NewGroupForm() {

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//from   w  ww  .java2s. c om
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    // field properties
    tfName.setSizeFull();

    mainVLayout.addComponent(tfName);

    Button btnSave = new Button("Save");
    mainVLayout.addComponent(btnSave);

    btnSave.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            // get hold of the business logic

            String name = tfName.getValue();

            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();
            String newGroupId = bl.saveNewGroup(name);

            if (newGroupId != null) {
                //saved successfully
                Notification.show("Success", name + " saved", Notification.Type.TRAY_NOTIFICATION);
                resetFields();
            } else {
                //something bad happened
                Notification.show("Error", "\nGroup could not be saved", Notification.Type.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.bodyeditor.BodyEditorViewImpl.java

License:Open Source License

private void notImplemented() {
    Notification.show("", "Not implemented yet", Notification.Type.WARNING_MESSAGE);
}

From source file:com.oodrive.nuage.webui.component.VvrOperationComponent.java

License:Apache License

@Override
public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) {

    final HorizontalLayout operationLayout = new HorizontalLayout();
    operationLayout.setMargin(true);/* w w  w  .  j  ava 2s .co m*/
    operationLayout.setSpacing(true);
    operationLayout.setWidth("100%");

    // Start and description buttons
    // START/STOP
    final Button startStop = new Button();
    startStop.setWidth(BUTTON_WIDTH);
    startStop.addStyleName(Runo.BUTTON_BIG);

    final Resource iconStartStop;
    final String description;
    if (!model.isVvrStarted()) {
        iconStartStop = WebUiResources.getStartIcon();
        description = "Start";
    } else {
        iconStartStop = WebUiResources.getStopIcon();
        description = "Stop";
    }
    startStop.setIcon(iconStartStop);
    startStop.setDescription(description);

    operationLayout.addComponent(startStop);
    operationLayout.setExpandRatio(startStop, 1f);
    operationLayout.setComponentAlignment(startStop, Alignment.MIDDLE_LEFT);

    final UUID vvrUuid = model.getItemUuid();
    startStop.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            final boolean started = model.isVvrStarted();
            // Start/Stop are done in background
            if (!started) {
                WaitingComponent.executeBackground(model, new Background() {
                    @Override
                    public void processing() {
                        model.startVvr();
                    }

                    @Override
                    public void postProcessing() {
                        startStop.setIcon(WebUiResources.getStopIcon());
                        startStop.setDescription("Stop");
                        Notification.show("VVR started ", vvrUuid.toString(),
                                Notification.Type.TRAY_NOTIFICATION);
                    }
                });
            } else {
                WaitingComponent.executeBackground(model, new Background() {
                    @Override
                    public void processing() {
                        model.stopVvr();
                    }

                    @Override
                    public void postProcessing() {
                        startStop.setIcon(WebUiResources.getStartIcon());
                        startStop.setDescription("Start");
                        Notification.show("VVR stopped ", vvrUuid.toString(),
                                Notification.Type.TRAY_NOTIFICATION);
                    }
                });
            }
        }
    });

    // ATTRIBUTES
    final Button attributes = new Button();
    attributes.addStyleName(Runo.BUTTON_BIG);
    attributes.setWidth(BUTTON_WIDTH);

    operationLayout.addComponent(attributes);
    operationLayout.setExpandRatio(attributes, 1f);
    operationLayout.setComponentAlignment(attributes, Alignment.MIDDLE_LEFT);
    attributes.setIcon(WebUiResources.getSettingsIcon());
    attributes.setDescription("Settings");

    attributes.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final VvrAttributesWindow attributesWindow = new VvrAttributesWindow(vvrUuid);
                attributesWindow.add(model);
            } catch (final Exception e) {
                LOGGER.error("Can not get VVR attributes: ", e);
                final ErrorWindow err = new ErrorWindow("Can not display VVR Attributes: " + e.getMessage());
                err.add(model);
            }
        }
    });

    // DELETE
    final Button delete = new Button();
    delete.addStyleName(Runo.BUTTON_BIG);
    delete.setWidth(BUTTON_WIDTH);
    delete.setIcon(WebUiResources.getTrashIcon());
    delete.setDescription("Delete");

    operationLayout.addComponent(delete);
    operationLayout.setExpandRatio(delete, 12f);
    operationLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT);

    delete.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final VvrDeleteWindow deleteWindow = new VvrDeleteWindow(vvrUuid);
                deleteWindow.add(vvrManagerModel);
            } catch (final Exception e) {
                LOGGER.error("Can not delete VVR: ", e);
                final ErrorWindow err = new ErrorWindow("Can not delete VVR: " + e.getMessage());
                err.add(model);
            }
        }
    });
    return operationLayout;
}