Java 类com.vaadin.server.DefaultErrorHandler 实例源码

项目:metasfresh-procurement-webui    文件:AbstractErrorHandler.java   
@Override
public final void error(final ErrorEvent event)
{
    //
    // Extract the relevant exception
    Throwable t = event.getThrowable();
    if (t instanceof SocketException)
    {
        // Most likely client browser closed socket
        logger.info("SocketException in CommunicationManager. Most likely client (browser) closed socket.");
        return;
    }
    t = DefaultErrorHandler.findRelevantThrowable(t);

    //
    // Create error message
    final ErrorMessage errorMessage = createErrorMessage(t);

    //
    // Display it
    displayError(errorMessage, event);

    // also print the error on console
    logger.error("", t);
}
项目:cuba    文件:InvalidValueExceptionHandler.java   
@Override
public boolean handle(ErrorEvent event, App app) {
    boolean handled = super.handle(event, app);

    //noinspection ThrowableResultOfMethodCallIgnored
    if (handled && event.getThrowable() != null) {
        // Finds the original source of the error/exception
        AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event);
        if (component != null) {
            component.markAsDirty();
        }

        if (component instanceof Component.Focusable) {
            ((Component.Focusable) component).focus();
        }

        //noinspection ThrowableResultOfMethodCallIgnored
        if (event.getThrowable() instanceof Validator.InvalidValueException) {
            app.getAppUI().discardAccumulatedEvents();
        }
    }
    return handled;
}
项目:vaadin4spring    文件:SingleSecuredUI.java   
@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Managed Security Demo");
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(new DefaultErrorHandler() {
        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                Notification.show("Sorry, you don't have access to do that.");
            } else {
                super.error(event);
            }
        }
    });
    if (vaadinSecurity.isAuthenticated()) {
        showMainScreen();
    } else {
        showLoginScreen(request.getParameter("goodbye") != null);
    }
}
项目:vaadin4spring    文件:MainUI.java   
@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo");
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(new DefaultErrorHandler() {
        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                Notification.show("Sorry, you don't have access to do that.");
            } else {
                super.error(event);
            }
        }
    });
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    // By adding a security item filter, only views that are accessible to the user will show up in the side bar.
    sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
    layout.addComponent(sideBar);

    CssLayout viewContainer = new CssLayout();
    viewContainer.setSizeFull();
    layout.addComponent(viewContainer);
    layout.setExpandRatio(viewContainer, 1f);

    Navigator navigator = new Navigator(this, viewContainer);
    // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all.
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(ErrorView.class);
    navigator.navigateTo(navigator.getState());

    setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI.
}
项目:VaadinUtils    文件:ErrorWindow.java   
public ErrorWindow()
{
    // Configure the error handler for the UI
    UI.getCurrent().setErrorHandler(new DefaultErrorHandler()
    {
        private static final long serialVersionUID = 1L;

        @Override
        public void error(com.vaadin.server.ErrorEvent event)
        {
            new ErrorWindow(true).internalShowErrorWindow(event.getThrowable());
        }

    });
}
项目:bbplay    文件:MainUI.java   
@Override
protected void init(VaadinRequest request) {
    getUI().setLocale(BBPlay.getLanguage(request.getLocale().getLanguage()));
    I18n.init(i18n);
    getPage().setTitle("BBPlay");
    setErrorHandler(new DefaultErrorHandler() {
        private static final long serialVersionUID = -18984634551415736L;

        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                BBPlay.error(I18n.t("error.noAccess", "MainUI"));
            } else {
                super.error(event);
            }
        }
    });
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    layout.addComponent(horizontalLayout);
    layout.setExpandRatio(horizontalLayout, 1f);

    sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
    horizontalLayout.addComponent(sideBar);

    CssLayout viewContainer = new CssLayout();
    viewContainer.setSizeFull();
    viewContainer.addStyleName("scrollable-y");
    horizontalLayout.addComponent(viewContainer);
    horizontalLayout.setExpandRatio(viewContainer, 1f);

    Navigator navigator = new Navigator(this, viewContainer);
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(NavigatorErrorView.class);

    Footer footer = new Footer();
    layout.addComponent(footer);
    layout.addComponent(animator = new AnimatorProxy());

    setContent(layout);
}
项目:trader    文件:TraderUI.java   
@Override
protected void init(VaadinRequest request) {
    setLocale(Locale.ENGLISH);
       // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
       setErrorHandler(new DefaultErrorHandler() {
           @Override
           public void error(com.vaadin.server.ErrorEvent event) {
               if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                   Notification.show("Sorry, you don't have access to do that.");
               } else {
                   super.error(event);
               }
           }
       });

    VerticalLayout layout = new VerticalLayout();
    Panel viewContent = new Panel();
    MenuBar menu = new MenuBar();
    menu.addStyleName("navigation-menu");

    layout.addComponents(menu, viewContent);
    layout.setSizeFull();
    viewContent.setSizeFull();
    layout.setExpandRatio(viewContent, 1);

    menu.addItem("Trading Area", e -> onDashboardClicked());
    menu.addItem("Users", e -> onCustomersClicked());

    navigator = new Navigator(this, viewContent);
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
       navigator.addProvider(springViewProvider);
       navigator.setErrorView(ErrorView.class);
       setContent(layout);
       String state = navigator.getState();
       if(state != null && !state.isEmpty()) {
        navigator.navigateTo(state);
       }
       else {
        navigator.navigateTo(TradingAreaView.NAME);
       }

}