Search in sources :

Example 1 with AbstractComponent

use of com.vaadin.ui.AbstractComponent in project cuba by cuba-platform.

the class AppLog method log.

@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void log(ErrorEvent event) {
    Throwable t = event.getThrowable();
    if (t instanceof SilentException)
        return;
    if (t instanceof Validator.InvalidValueException)
        return;
    if (t instanceof SocketException || ExceptionUtils.getRootCause(t) instanceof SocketException) {
        // Most likely client browser closed socket
        LogItem item = new LogItem(LogLevel.WARNING, "SocketException in CommunicationManager. Most likely client (browser) closed socket.", null);
        log(item);
        return;
    }
    // Support Tomcat 8 ClientAbortException
    if (StringUtils.contains(ExceptionUtils.getMessage(t), "ClientAbortException")) {
        // Most likely client browser closed socket
        LogItem item = new LogItem(LogLevel.WARNING, "ClientAbortException on write response to client. Most likely client (browser) closed socket.", null);
        log(item);
        return;
    }
    Throwable rootCause = ExceptionUtils.getRootCause(t);
    if (rootCause == null)
        rootCause = t;
    Logging annotation = rootCause.getClass().getAnnotation(Logging.class);
    Logging.Type loggingType = annotation == null ? Logging.Type.FULL : annotation.value();
    if (loggingType == Logging.Type.NONE)
        return;
    // Finds the original source of the error/exception
    AbstractComponent component = DefaultErrorHandler.findAbstractComponent(event);
    StringBuilder msg = new StringBuilder();
    msg.append("Exception");
    if (component != null)
        msg.append(" in ").append(component.getClass().getName());
    msg.append(": ");
    if (loggingType == Logging.Type.BRIEF) {
        error(msg + rootCause.toString());
    } else {
        LogItem item = new LogItem(LogLevel.ERROR, msg.toString(), t);
        log(item);
    }
}
Also used : Logging(com.haulmont.cuba.core.global.Logging) SocketException(java.net.SocketException) AbstractComponent(com.vaadin.ui.AbstractComponent) SilentException(com.haulmont.cuba.core.global.SilentException)

Example 2 with AbstractComponent

use of com.vaadin.ui.AbstractComponent in project cuba by cuba-platform.

the class MenuBuilder method assignShortcut.

protected void assignShortcut(Window webWindow, AppMenu.MenuItem menuItem, MenuItem item) {
    KeyCombination itemShortcut = item.getShortcut();
    if (itemShortcut != null) {
        ShortcutListener shortcut = new MenuShortcutAction(menuItem, "shortcut_" + item.getId(), item.getShortcut());
        AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
        windowImpl.addShortcutListener(shortcut);
        appMenu.setMenuItemShortcutCaption(menuItem, itemShortcut.format());
    }
}
Also used : ShortcutListener(com.vaadin.event.ShortcutListener) MenuShortcutAction(com.haulmont.cuba.web.toolkit.MenuShortcutAction) AbstractComponent(com.vaadin.ui.AbstractComponent) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination)

Example 3 with AbstractComponent

use of com.vaadin.ui.AbstractComponent in project cuba by cuba-platform.

the class SideMenuBuilder method assignShortcut.

protected void assignShortcut(Window webWindow, SideMenu.MenuItem menuItem, MenuItem item) {
    KeyCombination itemShortcut = item.getShortcut();
    if (itemShortcut != null) {
        ShortcutListener shortcut = new SideMenuShortcutListener(menuItem, item);
        AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class);
        windowImpl.addShortcutListener(shortcut);
        if (Strings.isNullOrEmpty(menuItem.getBadgeText())) {
            menuItem.setDescription(itemShortcut.format());
        }
    }
}
Also used : ShortcutListener(com.vaadin.event.ShortcutListener) AbstractComponent(com.vaadin.ui.AbstractComponent) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination)

Example 4 with AbstractComponent

use of com.vaadin.ui.AbstractComponent in project linkki by linkki-framework.

the class LabelComponentWrapper method setValidationMessages.

@Override
public void setValidationMessages(MessageList messagesForProperty) {
    if (component instanceof AbstractComponent) {
        AbstractComponent field = (AbstractComponent) component;
        field.setComponentError(getErrorHandler(messagesForProperty));
    }
}
Also used : AbstractComponent(com.vaadin.ui.AbstractComponent)

Aggregations

AbstractComponent (com.vaadin.ui.AbstractComponent)4 KeyCombination (com.haulmont.cuba.gui.components.KeyCombination)2 ShortcutListener (com.vaadin.event.ShortcutListener)2 Logging (com.haulmont.cuba.core.global.Logging)1 SilentException (com.haulmont.cuba.core.global.SilentException)1 MenuShortcutAction (com.haulmont.cuba.web.toolkit.MenuShortcutAction)1 SocketException (java.net.SocketException)1