Example usage for com.vaadin.ui Notification setDelayMsec

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

Introduction

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

Prototype

public void setDelayMsec(int delayMsec) 

Source Link

Document

Sets the delay before the notification disappears.

Usage

From source file:org.activiti.explorer.NotificationManager.java

License:Apache License

public void showWarningNotification(String captionKey, String descriptionKey, Object... params) {
    Notification notification = new Notification(i18nManager.getMessage(captionKey) + "<br/>",
            MessageFormat.format(i18nManager.getMessage(descriptionKey), params),
            Notification.TYPE_WARNING_MESSAGE);
    notification.setDelayMsec(5000); // click to hide
    mainWindow.showNotification(notification);
}

From source file:org.apache.ace.webui.vaadin.VaadinClient.java

License:Apache License

private void initGrid() {
    User user = (User) getUser();//from   w  w w .  ja v a2  s  .com
    Authorization auth = m_userAdmin.getAuthorization(user);
    int count = 0;
    for (String role : new String[] { "viewArtifact", "viewFeature", "viewDistribution", "viewTarget" }) {
        if (auth.hasRole(role)) {
            count++;
        }
    }

    final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir) {
        @Override
        public void updateProgress(long readBytes, long contentLength) {
            Float percentage = new Float(readBytes / (float) contentLength);
            m_progress.setValue(percentage);
        }

        @Override
        protected void artifactsUploaded(List<UploadHandle> uploadedArtifacts) {
            StringBuilder failedMsg = new StringBuilder();
            StringBuilder successMsg = new StringBuilder();
            Set<String> selection = new HashSet<>();

            for (UploadHandle handle : uploadedArtifacts) {
                if (!handle.isSuccessful()) {
                    // Upload failed, so let's report this one...
                    appendFailure(failedMsg, handle);

                    m_log.log(LogService.LOG_ERROR, "Upload of " + handle.getFile() + " failed.",
                            handle.getFailureReason());
                } else {
                    try {
                        // Upload was successful, try to upload it to our OBR...
                        ArtifactObject artifact = uploadToOBR(handle);
                        if (artifact != null) {
                            selection.add(artifact.getDefinition());

                            appendSuccess(successMsg, handle);
                        }
                    } catch (ArtifactAlreadyExistsException exception) {
                        appendFailureExists(failedMsg, handle);

                        m_log.log(LogService.LOG_WARNING,
                                "Upload of " + handle.getFilename() + " failed, as it already exists!");
                    } catch (Exception exception) {
                        appendFailure(failedMsg, handle, exception);

                        m_log.log(LogService.LOG_ERROR, "Upload of " + handle.getFilename() + " failed.",
                                exception);
                    }
                }

                // We're done with this (temporary) file, so we can remove it...
                handle.cleanup();
            }

            m_artifactsPanel.setValue(selection);

            // Notify the user what the overall status was...
            Notification notification = createNotification(failedMsg, successMsg);
            getMainWindow().showNotification(notification);

            m_progress.setStyleName("invisible");
            m_statusLine.setStatus(notification.getCaption() + "...");
        }

        @Override
        protected void uploadStarted(UploadHandle upload) {
            m_progress.setStyleName("visible");
            m_progress.setValue(new Float(0.0f));

            m_statusLine.setStatus("Upload of '%s' started...", upload.getFilename());
        }

        private void appendFailure(StringBuilder sb, UploadHandle handle) {
            appendFailure(sb, handle, handle.getFailureReason());
        }

        private void appendFailure(StringBuilder sb, UploadHandle handle, Exception cause) {
            sb.append("<li>'").append(handle.getFile().getName()).append("': failed");
            if (cause != null) {
                sb.append(", possible reason:<br/>").append(cause.getMessage());
            }
            sb.append("</li>");
        }

        private void appendFailureExists(StringBuilder sb, UploadHandle handle) {
            sb.append("<li>'").append(handle.getFile().getName())
                    .append("': already exists in repository</li>");
        }

        private void appendSuccess(StringBuilder sb, UploadHandle handle) {
            sb.append("<li>'").append(handle.getFile().getName()).append("': added to repository</li>");
        }

        private Notification createNotification(StringBuilder failedMsg, StringBuilder successMsg) {
            String caption = "Upload completed";
            int delay = 500; // msec.
            StringBuilder notification = new StringBuilder();
            if (failedMsg.length() > 0) {
                caption = "Upload completed with failures";
                delay = -1;
                notification.append("<ul>").append(failedMsg).append("</ul>");
            }
            if (successMsg.length() > 0) {
                notification.append("<ul>").append(successMsg).append("</ul>");
            }
            if (delay < 0) {
                notification.append("<p>(click to dismiss this notification).</p>");
            }

            Notification summary = new Notification(caption, notification.toString(),
                    Notification.TYPE_TRAY_NOTIFICATION);
            summary.setDelayMsec(delay);
            return summary;
        }

        private ArtifactObject uploadToOBR(UploadHandle handle) throws IOException {
            return UploadHelper.importRemoteBundle(m_artifactRepository, handle.getFile());
        }
    };

    m_grid = new GridLayout(count, 4);
    m_grid.setSpacing(true);
    m_grid.setSizeFull();

    m_mainToolbar = createToolbar();
    m_grid.addComponent(m_mainToolbar, 0, 0, count - 1, 0);

    m_artifactsPanel = createArtifactsPanel();
    m_artifactToolbar = createArtifactToolbar();

    final DragAndDropWrapper artifactsPanelWrapper = new DragAndDropWrapper(m_artifactsPanel);
    artifactsPanelWrapper.setDragStartMode(DragStartMode.HTML5);
    artifactsPanelWrapper.setDropHandler(new ArtifactDropHandler(uploadHandler));
    artifactsPanelWrapper.setCaption(m_artifactsPanel.getCaption());
    artifactsPanelWrapper.setSizeFull();

    count = 0;
    if (auth.hasRole("viewArtifact")) {
        m_grid.addComponent(artifactsPanelWrapper, count, 2);
        m_grid.addComponent(m_artifactToolbar, count, 1);
        count++;
    }

    m_featuresPanel = createFeaturesPanel();
    m_featureToolbar = createFeatureToolbar();

    if (auth.hasRole("viewFeature")) {
        m_grid.addComponent(m_featuresPanel, count, 2);
        m_grid.addComponent(m_featureToolbar, count, 1);
        count++;
    }

    m_distributionsPanel = createDistributionsPanel();
    m_distributionToolbar = createDistributionToolbar();

    if (auth.hasRole("viewDistribution")) {
        m_grid.addComponent(m_distributionsPanel, count, 2);
        m_grid.addComponent(m_distributionToolbar, count, 1);
        count++;
    }

    m_targetsPanel = createTargetsPanel();
    m_targetToolbar = createTargetToolbar();

    if (auth.hasRole("viewTarget")) {
        m_grid.addComponent(m_targetsPanel, count, 2);
        m_grid.addComponent(m_targetToolbar, count, 1);
    }

    m_statusLine = new StatusLine();

    m_grid.addComponent(m_statusLine, 0, 3, 2, 3);

    m_progress = new ProgressIndicator(0f);
    m_progress.setStyleName("invisible");
    m_progress.setIndeterminate(false);
    m_progress.setPollingInterval(1000);

    m_grid.addComponent(m_progress, 3, 3);

    m_grid.setRowExpandRatio(2, 1.0f);

    m_grid.setColumnExpandRatio(0, 0.31f);
    m_grid.setColumnExpandRatio(1, 0.23f);
    m_grid.setColumnExpandRatio(2, 0.23f);
    m_grid.setColumnExpandRatio(3, 0.23f);

    // Wire up all panels so they have the correct associations...
    m_artifactsPanel.setAssociatedTables(null, m_featuresPanel);
    m_featuresPanel.setAssociatedTables(m_artifactsPanel, m_distributionsPanel);
    m_distributionsPanel.setAssociatedTables(m_featuresPanel, m_targetsPanel);
    m_targetsPanel.setAssociatedTables(m_distributionsPanel, null);

    addListener(m_statusLine, StatefulTargetObject.TOPIC_ALL,
            RepositoryObject.PUBLIC_TOPIC_ROOT.concat(RepositoryObject.TOPIC_ALL_SUFFIX));
    addListener(m_mainToolbar, StatefulTargetObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_artifactsPanel, ArtifactObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_featuresPanel, FeatureObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_distributionsPanel, DistributionObject.TOPIC_ALL, RepositoryAdmin.TOPIC_STATUSCHANGED,
            RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);
    addListener(m_targetsPanel, StatefulTargetObject.TOPIC_ALL, TargetObject.TOPIC_ALL,
            RepositoryAdmin.TOPIC_STATUSCHANGED, RepositoryAdmin.TOPIC_LOGIN, RepositoryAdmin.TOPIC_REFRESH);

    m_mainWindow.addComponent(m_grid);
    // Ensure the focus is properly defined (for the shortcut keys to work)...
    m_mainWindow.focus();
}

From source file:org.dussan.vaadin.dcharts.test.DChartsTestUI.java

License:Apache License

private void showEventNotification(String event, Object chartObject) {
    String caption = "<span style='color:#ff6600'>Event: " + event + "</span>";
    StringBuilder description = new StringBuilder();

    if (chartObject instanceof ChartData) {
        ChartData chartData = (ChartData) chartObject;
        description.append("<b>Chart id:</b> " + chartData.getChartId());

        if (chartData.getSeriesIndex() != null) {
            description.append("<br /><b>Series index:</b> " + chartData.getSeriesIndex());
        }//  w  ww. j a  v  a 2s . c o m

        if (chartData.getPointIndex() != null) {
            description.append("<br /><b>Point index:</b> " + chartData.getPointIndex());
        }

        if (chartData.getData() != null) {
            description.append("<br /><b>Chart data:</b> " + Arrays.toString(chartData.getData()));
        }

        if (chartData.getOriginData() != null) {
            if (chartData.getOriginData() instanceof Object[]) {
                description.append(
                        "<br /><b>Origin data:</b> " + Arrays.toString((Object[]) chartData.getOriginData()));
            } else {
                description.append("<br /><b>Origin data:</b> " + chartData.getOriginData().toString());
            }
        }
    } else if (chartObject instanceof BufferedImage) {
        BufferedImage chartImage = (BufferedImage) chartObject;
        description.append("<b>Chart image width:</b> " + chartImage.getWidth() + "px");
        description.append("<br /><b>Chart image height:</b> " + chartImage.getHeight() + "px");
    }

    Notification notification = new Notification(caption, description.toString(), Type.TRAY_NOTIFICATION);
    notification.setDelayMsec(3000);
    notification.setHtmlContentAllowed(true);
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java

License:Open Source License

private void loginAuthenticationFailedNotification() {
    final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.description"));
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(1_000);
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java

License:Open Source License

private void loginCredentialsExpiredNotification() {
    final Notification notification = new Notification(
            i18n.getMessage("notification.login.failed.credentialsexpired.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description"));
    notification.setDelayMsec(10_000);
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closeable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.LoginView.java

License:Open Source License

void loginAuthenticationFailedNotification() {
    final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.description"));
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(1000);
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.LoginView.java

License:Open Source License

void loginCredentialsExpiredNotification() {
    final Notification notification = new Notification(
            i18n.getMessage("notification.login.failed.credentialsexpired.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description"));
    notification.setDelayMsec(10000);
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closeable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.show(Page.getCurrent());
}

From source file:org.esn.esobase.view.tab.ChangePasswordTab.java

private void changePasswordAction() {
    sysAccountService.updateUserPassword(SpringSecurityHelper.getSysAccount(), password.getValue());
    Notification n = new Notification(" ?", " ? ",
            Notification.Type.HUMANIZED_MESSAGE);
    n.setDelayMsec(2000);
    n.show(getUI().getPage());/* w w w. ja v  a  2 s.  c om*/
    TabSheet tabs = (TabSheet) this.getParent();
    tabs.removeTab(tabs.getTab(this));

}

From source file:org.esn.esobase.view.tab.QuestsTab.java

private void SaveForm() {
    try {/*from   www  .j a  v a2 s .c  om*/
        fieldGroup.commit();
        Quest entity = (Quest) currentItem.getBean();
        service.saveEntity(entity);
        CloseForm();
        LoadTable();
        Notification notification = new Notification("? ?",
                Notification.Type.HUMANIZED_MESSAGE);
        notification.setDelayMsec(2000);
        notification.show(this.getUI().getPage());
    } catch (FieldGroup.CommitException ex) {
        Logger.getLogger(QuestsTab.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.esn.esobase.view.tab.SystemSettingsTab.java

public SystemSettingsTab(DBService service_) {
    this.service = service_;

    FormLayout fl = new FormLayout();
    isAutoSyncEnabledBox = new CheckBox("??? ");
    fl.addComponent(isAutoSyncEnabledBox);
    HorizontalLayout hl = new HorizontalLayout();
    Button saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override//from w ww  .j a  v a  2 s.c  o m
        public void buttonClick(Button.ClickEvent event) {
            service.setIsAutoSynchronizationEnabled(isAutoSyncEnabledBox.getValue());
            LoadData();
            Notification notification = new Notification("?? ? ?",
                    Notification.Type.HUMANIZED_MESSAGE);
            notification.setDelayMsec(2000);
            notification.show(isAutoSyncEnabledBox.getUI().getPage());
        }
    });
    Button cancelButton = new Button("");
    cancelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadData();
        }
    });
    hl.addComponent(cancelButton);
    hl.addComponent(saveButton);
    fl.addComponent(hl);
    this.addComponent(fl);
    LoadData();
}