Example usage for com.vaadin.ui Notification TYPE_ERROR_MESSAGE

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

Introduction

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

Prototype

Type TYPE_ERROR_MESSAGE

To view the source code for com.vaadin.ui Notification TYPE_ERROR_MESSAGE.

Click Source Link

Usage

From source file:com.expressui.core.MainApplication.java

License:Open Source License

@Override
public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) {
    Throwable rootThrowable = event.getThrowable();
    if (rootThrowable == null)
        return;/*from  ww  w. j a  v a  2s .co  m*/

    Exception cause;
    if ((cause = ExceptionUtil.findThrowableInChain(rootThrowable,
            DataIntegrityViolationException.class)) != null) {
        log.warn("Terminal error: ", rootThrowable);
        getMainWindow().showNotification(uiMessageSource.getMessage("mainApplication.dataConstraintViolation"),
                cause.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
    } else if ((cause = ExceptionUtil.findThrowableInChain(rootThrowable,
            ConstraintViolationException.class)) != null) {
        log.warn("Terminal error: ", rootThrowable);
        ConstraintViolationException violationException = (ConstraintViolationException) cause;
        getMainWindow().showNotification(uiMessageSource.getMessage("mainApplication.dataConstraintViolation"),
                violationException.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
    } else if ((cause = ExceptionUtil.findThrowableInChain(rootThrowable,
            EntityNotFoundException.class)) != null) {
        log.warn("Terminal error: ", rootThrowable);
        getMainWindow().showNotification(uiMessageSource.getMessage("mainApplication.entityNotFound"),
                Window.Notification.TYPE_ERROR_MESSAGE);
    } else {
        super.terminalError(event);
        log.error("Terminal error: ", rootThrowable);
        openErrorWindow(rootThrowable);
    }
}

From source file:com.expressui.core.MainApplication.java

License:Open Source License

/**
 * Shows big error box to user./* w  ww. j a  va2  s .  co m*/
 *
 * @param errorMessage message to display
 */
public void showError(String errorMessage) {
    getMainWindow().showNotification(errorMessage, Window.Notification.TYPE_ERROR_MESSAGE);
}

From source file:com.expressui.core.view.form.EntityForm.java

License:Open Source License

/**
 * Shows notification message that save was unsuccessful because of a conflict with another user's changes.
 *///from   w w w  .ja  va 2s .  c  o  m
public void showSaveConflictMessage() {
    Window.Notification notification = new Window.Notification(
            uiMessageSource.getMessage("entityForm.saveConflictError"), Window.Notification.TYPE_ERROR_MESSAGE);
    notification.setDelayMsec(Window.Notification.DELAY_NONE);
    notification.setPosition(Window.Notification.POSITION_CENTERED);
    getMainApplication().showNotification(notification);
}

From source file:com.expressui.core.view.form.EntityForm.java

License:Open Source License

/**
 * Shows notification message that save was unsuccessful because of validation error.
 *//*  www. j a v  a  2s.  c  o m*/
public void showSaveValidationErrorMessage() {
    Window.Notification notification = new Window.Notification(
            uiMessageSource.getMessage("entityForm.saveValidationError", new Object[] { getEntityCaption() }),
            Window.Notification.TYPE_ERROR_MESSAGE);
    notification.setDelayMsec(Window.Notification.DELAY_NONE);
    notification.setPosition(Window.Notification.POSITION_CENTERED);
    getMainApplication().showNotification(notification);
}

From source file:com.trivago.mail.pigeon.web.components.groups.ModalRecipientImportCsv.java

License:Apache License

public ModalRecipientImportCsv(final long groupId) {
    super();//from   w w w . j  a  v a 2s  .  c  o m
    setModal(true);
    setClosable(false);
    setWidth("600px");

    Panel rootPanel = new Panel("Import Recipients via CSV");
    VerticalLayout vl = new VerticalLayout();

    Label infoText = new Label(
            "You can upload a bunch of users into a group. Create a CSV file with no! headers. \n"
                    + "You can leave out the user_id by just setting the column empty => ,\"Firstname Lastname\",\"first.last@trivago.com\".");
    Label formatInfoText = new Label("Please format you CSV like: user_id,\"user_full_name\",\"email\"");

    final CheckBox forceUpdate = new CheckBox("Force update of existing recipients?");
    Button cancelButton = new Button("Cancel");

    vl.addComponent(infoText);
    vl.addComponent(formatInfoText);
    final UploadCsvFileComponent ucsv = new UploadCsvFileComponent();
    vl.addComponent(ucsv);

    Button importButton = new Button("Import");
    importButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!ucsv.isUploadFinished()) {
                ucsv.setComponentError(new UserError("Please upload a csv first!"));
            } else {
                ucsv.setComponentError(null);

                try {
                    File uploadedFile = ucsv.getCsvFile();
                    Csv importer = new Csv(uploadedFile, groupId);
                    importer.importData(forceUpdate.booleanValue());
                    event.getButton().getApplication().getMainWindow().showNotification("Import done",
                            Notification.TYPE_HUMANIZED_MESSAGE);
                    event.getButton().getWindow().setVisible(false);
                    event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow());

                } catch (Exception e) {
                    log.error("Error while importing csv", e);
                    event.getButton().getWindow().showNotification("The import failed.",
                            e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE);
                }
            }
        }
    });

    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            event.getButton().getWindow().setVisible(false);
            event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow());
        }
    });

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(importButton);
    buttonLayout.addComponent(cancelButton);

    vl.addComponent(buttonLayout);
    rootPanel.addComponent(vl);
    addComponent(rootPanel);
}

From source file:com.trivago.mail.pigeon.web.components.mail.ModalAddNewsletter.java

License:Apache License

public ModalAddNewsletter(final NewsletterList nl) {
    super();/*from  w w w . ja v a 2s. c  o m*/

    setModal(true);
    setWidth("600px");
    setClosable(false);

    Panel rootPanel = new Panel("Add new Newsletter");
    final VerticalLayout verticalLayout = new VerticalLayout();
    final SenderSelectBox senderSelectBox = new SenderSelectBox();
    final HorizontalLayout buttonLayout = new HorizontalLayout();
    final GroupSelectBox groupSelectBox = new GroupSelectBox();
    final UploadTextFileComponent uploadTextfile = new UploadTextFileComponent();
    final UploadHtmlFileComponent uploadHtmlfile = new UploadHtmlFileComponent();
    final TemplateSelectBox templateSelectBox = new TemplateSelectBox();
    final TextField tfSubject = new TextField("Subject");
    final DateField tfSendDate = new DateField("Send Date");
    final Button cancelButton = new Button("Cancel");
    final Button saveButton = new Button("Send");

    tfSendDate.setInvalidAllowed(false);
    tfSendDate.setResolution(DateField.RESOLUTION_MIN);
    tfSendDate.setValue(new Date());

    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            event.getButton().getWindow().setVisible(false);
            event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow());
        }
    });

    saveButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean hasError = false;
            // Validation
            if (tfSubject.getValue().equals("") && templateSelectBox.getSelectedTemplate() == null) {
                hasError = true;
                tfSubject.setComponentError(
                        new UserError("Subject cannot be empty if you do not choose a template."));
            } else {
                tfSubject.setComponentError(null);
            }

            if (tfSendDate.getValue() == null) {
                hasError = true;
                tfSendDate.setComponentError(new UserError("Date cannot be empty"));
            } else {
                tfSendDate.setComponentError(null);
            }

            if (templateSelectBox.getSelectedTemplate() == null) {
                if (!uploadTextfile.isUploadFinished()) {
                    hasError = true;
                    uploadTextfile.setComponentError(
                            new UserError("You must provide a text file if you do not choose a template"));
                } else {
                    uploadTextfile.setComponentError(null);
                }

                if (!uploadHtmlfile.isUploadFinished()) {
                    hasError = true;
                    uploadHtmlfile.setComponentError(
                            new UserError("You must provide a html file if you do not choose a template"));
                } else {
                    uploadHtmlfile.setComponentError(null);
                }
            }

            if (senderSelectBox.getSelectedSender() == 0) {
                hasError = true;
                senderSelectBox.setComponentError(new UserError("You must select a sender"));
            } else {
                senderSelectBox.setComponentError(null);
            }

            if (groupSelectBox.getSelectedGroup() == 0) {
                hasError = true;
                groupSelectBox.setComponentError(new UserError("You must select a recipient group"));
            } else {
                groupSelectBox.setComponentError(null);
            }
            log.debug("Has Error: " + hasError);
            if (!hasError) {
                log.info("No validation errors found, processing request");
                long mailId = Util.generateId();
                try {
                    Sender s = new Sender(senderSelectBox.getSelectedSender());

                    String text;
                    String html;
                    String subject;

                    if (templateSelectBox.getSelectedTemplate() == null) {
                        text = uploadTextfile.getTextData();
                        html = uploadHtmlfile.getHtmlData();
                        subject = tfSubject.getValue().toString();
                    } else {
                        MailTemplate mt = new MailTemplate(templateSelectBox.getSelectedTemplate());
                        text = mt.getText();
                        html = mt.getHtml();
                        subject = mt.getSubject();
                    }

                    Mail m = new Mail(mailId, text, html, (Date) tfSendDate.getValue(), subject, s);

                    QueueNewsletter queueNewsletter = new QueueNewsletter();
                    queueNewsletter.queueNewsletter(m, s,
                            new RecipientGroup(groupSelectBox.getSelectedGroup()));

                    event.getButton().getWindow().setVisible(false);
                    event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow());
                    event.getButton().getWindow().getParent().showNotification("Queued successfully",
                            Notification.TYPE_HUMANIZED_MESSAGE);

                    nl.getBeanContainer().addItem(m.getId(), m);

                } catch (RuntimeException e) {
                    log.error("RuntimeException", e);
                    event.getButton().getApplication().getMainWindow().showNotification(
                            "An error occured: " + e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE);
                }
            }
        }
    });

    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(saveButton);
    buttonLayout.addComponent(cancelButton);

    Panel metaData = new Panel("Basic Data");

    metaData.addComponent(tfSendDate);
    verticalLayout.addComponent(metaData);
    verticalLayout.addComponent(senderSelectBox);
    verticalLayout.addComponent(groupSelectBox);

    verticalLayout.addComponent(templateSelectBox);

    verticalLayout.addComponent(tfSubject);
    verticalLayout.addComponent(uploadTextfile);
    verticalLayout.addComponent(uploadHtmlfile);

    verticalLayout.addComponent(buttonLayout);

    rootPanel.addComponent(verticalLayout);
    this.addComponent(rootPanel);
}

From source file:eu.lod2.DeleteGraphs.java

License:Apache License

/**
 * Takes the currently marked graphs in the table and destroys the graphs. Asks for confirmation first.
 * Resets the entire table after selection.
 * @param event : the clickevent that fired the call
 *///from  w  w w.  j av  a  2  s  .  co  m
private void deletegraphs(ClickEvent event) {
    Button yesOption = showConfirmDialog(
            "Warning! This function will result in the complete and irretrievable removal of the selected graphs.\n\n "
                    + "Do you wish to continue?");
    final DeleteGraphs panel = this;

    yesOption.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            try {
                panel.doDeleteGraphs();
            } catch (Exception e) {
                getWindow().showNotification("Graph removal failed",
                        "Remove the graphs. " + "Received " + e.getClass().getSimpleName()
                                + " error with message: " + e.getMessage(),
                        Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
}

From source file:eu.lod2.EXML.java

License:Apache License

private void showExceptionMessage(Exception e) {

    this.getWindow().showNotification(
            "The operation failed due some errors. See for detailed information to the catalina log. ",
            e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
}

From source file:eu.lod2.LOD2Demo.java

License:Apache License

@Override
public void init() {
    state = new LOD2DemoState();

    mainWindow = new Window("LOD2 Prototype");
    setTheme("lod2");
    mainContainer = new VerticalLayout();
    mainWindow.addComponent(mainContainer);
    mainContainer.setSizeFull();/*  w  w w.  j  a va  2s .c  om*/

    final AbsoluteLayout welcomeSlagzin = new AbsoluteLayout();
    welcomeSlagzin.setWidth("370px");
    welcomeSlagzin.setHeight("75px");
    final Link homepage = new Link();
    homepage.setResource(new ExternalResource("http://lod2.eu"));
    final ThemeResource logo = new ThemeResource("app_images/logo-lod2-small.png");
    homepage.setIcon(logo);
    welcomeSlagzin.addComponent(homepage, "top:0px; left:5px");
    homepage.setSizeFull();
    homepage.addStyleName("logo");

    // the current graph as label
    /*
    currentgraphlabel = new Label("no current graph selected");
    currentgraphlabel.addStyleName("currentgraphlabel");
    */

    Button homeb = new Button("home");
    homeb.setDebugId(this.getClass().getSimpleName() + "_homeb");
    homeb.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            home();
        }
    });
    homeb.setStyleName(BaseTheme.BUTTON_LINK);
    homeb.addStyleName("currentgraphlabel");

    currentgraphlabel = state.cGraph;
    currentgraphlabel.addStyleName("currentgraphlabel");
    // Create an horizontal container
    HorizontalLayout welcomeContainer = new HorizontalLayout();

    //menubarContainer.addComponent(lod2logo);
    welcomeContainer.addComponent(welcomeSlagzin);
    welcomeContainer.setComponentAlignment(welcomeSlagzin, Alignment.TOP_LEFT);
    welcomeContainer.addComponent(homeb);
    welcomeContainer.setComponentAlignment(homeb, Alignment.TOP_RIGHT);
    welcomeContainer.addComponent(currentgraphlabel);
    welcomeContainer.setComponentAlignment(currentgraphlabel, Alignment.TOP_RIGHT);

    final VerticalLayout welcome = new VerticalLayout();
    welcome.addComponent(welcomeContainer);
    // unfortunately, we need to be able to build components from outside
    // this initialization function and the welcome component needs to be
    // resized properly afterward
    this.welcome = welcome;

    mainContainer.addComponent(welcome);

    //************************************************************************
    //  menu bar style
    //
    MenuBar menubar = new MenuBar();
    menubar.setDebugId(this.getClass().getSimpleName() + "_menubar");

    // First define all menu commands

    MenuBar.Command me1c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ELoadRDFFile content = new ELoadRDFFile(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me3c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EXML me3c_content = new EXML(state);
            workspace.addComponent(me3c_content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            me3c_content.setSizeFull();
        }
    };
    MenuBar.Command me3cbis = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EXMLExtended content = new EXMLExtended(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
        }
    };

    MenuBar.Command me4c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ESpotlight content = new ESpotlight(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me5c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EPoolPartyExtractor me5c_content = new EPoolPartyExtractor(state);
            workspace.addComponent(me5c_content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            me5c_content.setHeight("90%");
        }
    };

    MenuBar.Command me6c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            D2RCordis content = new D2RCordis(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me7c_1 = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://publicdata.eu/dataset?res_format=RDF&q=rdf");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me7c_2 = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://datahub.io/dataset?groups=lodcloud");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command me8c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EURL content = new EURL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("90%");
        }
    };

    MenuBar.Command me9c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            EPoolPartyLabel content = new EPoolPartyLabel(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("90%");
        }
    };

    MenuBar.Command silk = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            LinkingTab lsilk = new LinkingTab(state);
            workspace.addComponent(lsilk);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            lsilk.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(lsilk, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command limes = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            Limes limes = new Limes(state);
            workspace.addComponent(limes);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            limes.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(limes, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command sameaslinking = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SameAsLinking content = new SameAsLinking(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
        }
    };

    MenuBar.Command ore = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ORE content = new ORE(state);
            workspace.addComponent(content);
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command lodrefine = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            Lodrefine content = new Lodrefine(state);
            workspace.addComponent(content);
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mconfiguration = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            ConfigurationTab content = new ConfigurationTab(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("500px");
        }
    };

    MenuBar.Command mabout = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            About content = new About(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
        }
    };

    MenuBar.Command mau = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            OntoWiki content = new OntoWiki(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq1c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SesameSPARQL content = new SesameSPARQL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq2c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            OntoWikiQuery content = new OntoWikiQuery(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq3c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            VirtuosoSPARQL content = new VirtuosoSPARQL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mq4c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            VirtuosoISPARQL content = new VirtuosoISPARQL(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    /** Deprecated temporarily
    MenuBar.Command mq5c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            GeoSpatial content = new GeoSpatial(state);
            workspace.addComponent(content);
          resetSizeFull(workspace);
            welcome.setHeight("110px");
          workspace.setSizeFull();
          workspace.setHeight("500px");
          workspace.setExpandRatio(content,1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
        }
    };
            
    MenuBar.Command mq_s_6c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
           workspace.removeAllComponents();
            Sparqled content = new Sparqled(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
            
    MenuBar.Command mq_s_7c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
           workspace.removeAllComponents();
            SparqledManager content = new SparqledManager(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
    */

    MenuBar.Command mo1c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SameAs content = new SameAs(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setHeight("500px");
        }
    };

    /** Deprecated temporarily
    MenuBar.Command mo2c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            Sigma content = new Sigma(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
    */

    MenuBar.Command mo3c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            LODCloud content = new LODCloud(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo4c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            DBpedia content = new DBpedia(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo5c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            SPARQLPoolParty content = new SPARQLPoolParty(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo6c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            OnlinePoolParty content = new OnlinePoolParty(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo7c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            MondecaSPARQLList content = new MondecaSPARQLList(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo8c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            CKAN content = new CKAN(state);
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command mo9c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://publicdata.eu");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    /** Deprecated temporarily
    MenuBar.Command mo10c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://sig.ma");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };
    */

    MenuBar.Command mo11c = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            workspace.removeAllComponents();
            IframedUrl content = new IframedUrl(state, "http://sindice.com");
            workspace.addComponent(content);
            // stretch the content to the full workspace area
            welcome.setHeight("110px");
            content.setSizeFull();
            workspace.setSizeFull();
            workspace.setExpandRatio(content, 1.0f);
            mainContainer.setExpandRatio(workspace, 2.0f);
            mainWindow.getContent().setSizeFull();
        }
    };

    MenuBar.Command userinfoCommand = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(/*new Authenticator(*/new UserInformation(state)/*, state)*/);
        }
    };

    MenuBar.Command publishCommand = new Command() {
        public void menuSelected(MenuItem selectedItem) {
            // publishing should be protected with an authenticator, otherwise a store could be published
            // without provenance information!
            showInWorkspace(/*new Authenticator(*/new CKANPublisherPanel(state)/*, state)*/);
        }
    };

    MenuBar.Command mDeleteGraphs = new MenuBar.Command() {
        public void menuSelected(MenuItem selectedItem) {
            showInWorkspace(/*new Authenticator(*/new DeleteGraphs(state)/*, state)*/);
        }
    };

    // Secondly define menu layout
    // root menu's
    MenuBar.MenuItem extraction = menubar.addItem("Extraction & Loading", null, null);
    MenuBar.MenuItem querying = menubar.addItem("Querying & Exploration", null, null);
    MenuBar.MenuItem authoring = menubar.addItem("Authoring", null, null);
    MenuBar.MenuItem linking = menubar.addItem("Linking", null, null);
    MenuBar.MenuItem enrichment = menubar.addItem("Enrichment & Data Cleaning", null, null);
    MenuBar.MenuItem onlinetools = menubar.addItem("Online Tools & Services", null, null);
    MenuBar.MenuItem configuration = menubar.addItem("Configuration", null, null);

    // sub menu's 
    MenuBar.MenuItem me1 = extraction.addItem("Upload RDF file or RDF from URL", null, me1c);
    //       MenuBar.MenuItem me1b = extraction.addItem("Import RDF data from URL", null, me8c);
    MenuBar.MenuItem me2_1 = extraction.addItem("Load RDF data from publicdata.eu", null, me7c_1);
    MenuBar.MenuItem me2_2 = extraction.addItem("Load LOD cloud RDF data from the Data Hub", null, me7c_2);
    MenuBar.MenuItem me3 = extraction.addItem("Extract RDF from XML", null, null);
    MenuBar.MenuItem me6 = extraction.addItem("Extract RDF from SQL", null, me6c);
    MenuBar.MenuItem me4 = extraction.addItem("Extract RDF from text w.r.t. DBpedia", null, me4c);
    MenuBar.MenuItem me5 = extraction.addItem("Extract RDF from text w.r.t. a controlled vocabulary", null,
            me5c);
    //       MenuBar.MenuItem me9  = extraction.addItem("Complete RDF w.r.t. a controlled vocabulary", null, me9c);

    MenuBar.MenuItem exml = me3.addItem("Basic extraction", null, me3c);
    MenuBar.MenuItem extended = me3.addItem("Extended extraction", null, me3cbis);

    MenuBar.MenuItem mq1 = querying.addItem("SPARQL querying", null, null);
    // Deprecated temporarily
    //MenuBar.MenuItem mq2 = querying.addItem("Sig.ma EE", null, mo2c);
    //MenuBar.MenuItem mq3 = querying.addItem("Geo-spatial exploration", null, mq5c);
    // TODO: replace this with a menu with two entries, editor and manager, after stephane fixes the manager
    //MenuBar.MenuItem mqs5 = mq1.addItem("SparQLed - Assisted Querying", null, mq_s_6c);
    //MenuBar.MenuItem mqsparqled1 = mqs5.addItem("Use currently selected graph", null, mq_s_6c);
    //MenuBar.MenuItem mqsparqled2 = mqs5.addItem("Use manager to calculate summary graph", null, mq_s_7c);
    //MenuBar.MenuItem mqs1 = mq1.addItem("Direct via Sesame API", null, mq1c);
    MenuBar.MenuItem mqs2 = mq1.addItem("OntoWiki SPARQL endpoint", null, mq2c);
    MenuBar.MenuItem mqs3 = mq1.addItem("Virtuoso SPARQL endpoint", null, mq3c);
    MenuBar.MenuItem mqs4 = mq1.addItem("Virtuoso interactive SPARQL endpoint", null, mq4c);

    MenuBar.MenuItem ma = authoring.addItem("OntoWiki", null, mau);
    MenuBar.MenuItem publishing = authoring.addItem("Publish to CKAN", null, publishCommand);

    MenuBar.MenuItem linking1 = linking.addItem("Silk", null, silk);
    MenuBar.MenuItem linking2 = linking.addItem("Limes", null, limes);
    MenuBar.MenuItem linking3 = linking.addItem("SameAs Linking", null, sameaslinking);

    MenuBar.MenuItem enrichment1 = enrichment.addItem("ORE", null, ore);
    MenuBar.MenuItem enrichment2 = enrichment.addItem("LOD enabled Refine", null, lodrefine);

    MenuBar.MenuItem sameAs = onlinetools.addItem("SameAs", null, mo1c);
    MenuBar.MenuItem sindice = onlinetools.addItem("Sindice", null, mo11c);
    //Deprecated temporarily
    //MenuBar.MenuItem sigmaOnline  = onlinetools.addItem("Sigma", null, mo10c);
    MenuBar.MenuItem ckan = onlinetools.addItem("CKAN", null, mo8c);
    MenuBar.MenuItem publicdata = onlinetools.addItem("Europe's Public Data", null, mo9c);
    MenuBar.MenuItem poolparty = onlinetools.addItem("PoolParty", null, mo6c);
    MenuBar.MenuItem sparqlonline = onlinetools.addItem("Online SPARQL endpoints", null, null);
    MenuBar.MenuItem lodcloud = sparqlonline.addItem("LOD cloud", null, mo3c);
    MenuBar.MenuItem dbpedia = sparqlonline.addItem("DBpedia", null, mo4c);
    MenuBar.MenuItem sparqlpoolparty = sparqlonline.addItem("PoolParty SPARQL endpoint", null, mo5c);
    MenuBar.MenuItem mondecalist = sparqlonline.addItem("Mondeca SPARQL endpoint Collection", null, mo7c);

    MenuBar.MenuItem conf = configuration.addItem("Demonstrator configuration", null, mconfiguration);
    MenuBar.MenuItem userconf = configuration.addItem("UserConfiguration", null, userinfoCommand);
    MenuBar.MenuItem about = configuration.addItem("About", null, mabout);
    MenuBar.MenuItem delgraphs = configuration.addItem("Delete Graphs", null, mDeleteGraphs);

    HorizontalLayout menubarContainer = new HorizontalLayout();
    menubarContainer.addComponent(menubar);
    menubarContainer.addStyleName("menubarContainer");
    menubarContainer.setWidth("100%");
    welcome.addComponent(menubarContainer);
    welcome.setHeight("110px");

    //************************************************************************
    // add workspace
    workspace = new VerticalLayout();

    mainContainer.addComponent(workspace);

    //create login/logout component that shows currently logged in user
    LoginStatus login = new LoginStatus(state, this.workspace);
    welcomeContainer.addComponent(login);
    welcomeContainer.setComponentAlignment(login, Alignment.TOP_RIGHT);
    welcomeContainer.setWidth("100%");

    /*
    workspace.setHeight("80%");
            
    HorizontalLayout introH = new HorizontalLayout();
    Embedded lod2cycle = new Embedded("", new ThemeResource("app_images/lod-lifecycle-small.png"));
    lod2cycle.setMimeType("image/png");
    introH.addComponent(lod2cycle);
    introH.setComponentAlignment(lod2cycle, Alignment.MIDDLE_LEFT);
            
    VerticalLayout introV =  new VerticalLayout();
    introH.addComponent(introV);
            
    Label introtextl =  new Label(introtext, Label.CONTENT_XHTML);
    introV.addComponent(introtextl);
    introtextl.setWidth("400px");
            
    HorizontalLayout introVH =  new HorizontalLayout();
    introV.addComponent(introVH);
            
    Embedded euflag = new Embedded("", new ThemeResource("app_images/eu-flag.gif"));
    euflag.setMimeType("image/gif");
    introVH.addComponent(euflag);
    euflag.addStyleName("eugif");
    euflag.setHeight("50px");
    Embedded fp7 = new Embedded("", new ThemeResource("app_images/fp7-gen-rgb_small.gif"));
    fp7.setMimeType("image/gif");
    fp7.addStyleName("eugif");
    fp7.setHeight("50px");
    introVH.addComponent(fp7);
            
    workspace.addComponent(introH);
    */
    home();

    // Create a tracker for the demo.lod2.eu domain.
    if (!state.googleAnalyticsID.equals("")) {
        //            GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker("UA-26375798-1", "demo.lod2.eu");
        GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker(state.googleAnalyticsID,
                state.googleAnalyticsDomain);
        mainWindow.addComponent(tracker);
        tracker.trackPageview("/lod2statworkbench");
    }
    ;

    setMainWindow(mainWindow);

    //       mainWindow.setExpandRatio(workspace, 1.0f);

    if (!state.InitStatus) {
        mainWindow.showNotification("Initialization Demonstration Failed", state.ErrorMessage,
                Notification.TYPE_ERROR_MESSAGE);
    }
    ;

}

From source file:eu.lod2.LOD2Demo.java

License:Apache License

@Override
public void terminalError(Terminal.ErrorEvent event) {
    Window errorWindow = mainWindow;

    try {//from  ww  w  .j  a  v a 2 s.  com
        UploadException uploadException = (UploadException) event.getThrowable();
        System.err.println(event.getThrowable().getMessage());
    } catch (Exception e) {
        // not an UploadException
        // Shows an error notification
        if (errorWindow != null) {
            StringWriter sw = new StringWriter();
            PrintWriter writer = new PrintWriter(sw);
            event.getThrowable().printStackTrace(writer);
            String stack = sw.toString();
            errorWindow.showNotification(
                    "An internal error has occurred, please " + "contact the administrator!",
                    "The error message was: \n" + stack, Notification.TYPE_ERROR_MESSAGE);
            System.err.println(event.getThrowable().getMessage());
            System.err.println(event.toString());
        }
    }

}