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, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:com.yoncabt.ebr.ui.ReportWindow.java

private void fillTheGridJRXML(ReportRequest request, EBRConnection con) throws SQLException, IOException {
    ReportTask task = reportService.request(request);
    if (task.getException() != null) {
        Notification.show("Hata", Notification.Type.ERROR_MESSAGE);
    } else {/*from w  w  w .  ja  v  a  2 s. co  m*/
        Page.getCurrent().open("/ebr/ws/1.0/output/" + request.getUuid(), "_blank");
    }
}

From source file:com.yoncabt.ebr.ui.ReportWindow.java

private void createMenuBar(MenuBar.MenuItem mainItem, File dir) throws IOException, JRException {
    //FIXME baz kodlar servise taabilir
    String menuText = dir.getName();
    File folderConfig = new File(dir, EBRParams.FOLDER_EBR_JSON);
    if (folderConfig.exists()) {
        try {/*from   ww  w.  j a  v a2 s.c o m*/
            JSONObject jo = new JSONObject(FileUtils.readFileToString(folderConfig, "utf-8"));
            menuText = jo.optString("label", menuText);
        } catch (IOException ex) {
            throw new IOException(folderConfig.getAbsolutePath(), ex);
        } catch (JSONException ex) {
            throw new JSONException(new RuntimeException(folderConfig.getAbsolutePath(), ex));
        }
    }
    MenuBar.MenuItem menuItem = mainItem.addItem(menuText, null);

    for (File file : dir.listFiles()) {
        if (file.getName().charAt(0) == '.') {
            continue;//gereksiz ama olduu belli olsun
        } else if (file.isDirectory()) {
            createMenuBar(menuItem, file);
        } else if (file.getName().endsWith(".sql") || file.getName().endsWith(".jrxml")) {
            BaseReport r = file.getName().endsWith(".sql") ? new SQLReport() : new JasperReport();
            context.getAutowireCapableBeanFactory().autowireBean(r);
            String text;
            try {
                text = r.loadDefinition(file).getCaption();
            } catch (ReportException ex) {
                Notification.show("Hata", Notification.Type.ERROR_MESSAGE);
                Logger.getLogger(ReportWindow.class.getName()).log(Level.SEVERE, null, ex);
                text = file.getName() + " ERROR";
            }
            menuItem.addItem(text, (MenuBar.MenuItem selectedItem) -> {
                System.out.println(r.getFile() + " altrlacak");
                String frag = StringUtils.removeStart(r.getFile().getAbsolutePath(),
                        EBRConf.INSTANCE.getValue(EBRParams.REPORTS_JRXML_PATH, ""));
                frag = StringUtils.removeStart(frag, "/");
                getPage().setUriFragment(frag);
            });
        } else if (file.getName().endsWith(".jrxml")) {//FIXME support for compiled jasper files
            final JasperReport r = new JasperReport();
            context.getAutowireCapableBeanFactory().autowireBean(r);
            String text = r.loadDefinition(file).getCaption();
            menuItem.addItem(text, (MenuBar.MenuItem selectedItem) -> {
                System.out.println(r.getFile() + " altrlacak");
                String frag = StringUtils.removeStart(r.getFile().getAbsolutePath(),
                        EBRConf.INSTANCE.getValue(EBRParams.REPORTS_JRXML_PATH, ""));
                frag = StringUtils.removeStart(frag, "/");
                getPage().setUriFragment(frag);
            });
        }
    }
}