com.save.global.ErrorLoggedNotification.java Source code

Java tutorial

Introduction

Here is the source code for com.save.global.ErrorLoggedNotification.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.save.global;

import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;

/**
 *
 * @author jetdario
 */
public class ErrorLoggedNotification {

    public ErrorLoggedNotification() {
    }

    public static void errorNotificationOnDBAccess(String error) {
        Notification.show(error, Notification.Type.ERROR_MESSAGE);
    }

    public static void showErrorLoggedOnWindow(String error, String className) {
        VerticalLayout v = new VerticalLayout();
        v.setSizeFull();
        v.setMargin(true);

        Window sub = new Window("ERROR MESSAGE!", v);
        sub.setWidth("500px");
        if (sub.getParent() == null) {
            UI.getCurrent().addWindow(sub);
        }
        sub.setModal(true);

        Panel panel = new Panel();
        panel.setSizeFull();
        panel.setContent(new Label(error + " on \n" + className, ContentMode.HTML));
        panel.getContent().setHeightUndefined();

        sub.setContent(panel);
        sub.getContent().setHeightUndefined();
    }

    public static void showWarningLoggedOnWindow(String warning, String className) {
        VerticalLayout v = new VerticalLayout();
        v.setSizeFull();
        v.setMargin(true);

        Window sub = new Window("WARNING MESSAGE!");
        sub.setWidth("500px");
        if (sub.getParent() == null) {
            UI.getCurrent().addWindow(sub);
        }
        sub.setModal(true);

        Panel panel = new Panel();
        panel.setSizeFull();
        panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
        panel.setContent(new Label(warning + " on \n" + className, ContentMode.HTML));
        panel.getContent().setHeightUndefined();
        v.addComponent(panel);

        sub.setContent(v);
        sub.getContent().setHeightUndefined();
    }
}