com.vaadin.server.Extension Java Examples

The following examples show how to use com.vaadin.server.Extension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CubaImageObjectFitPolyfillExtension.java    From cuba with Apache License 2.0 6 votes vote down vote up
public static CubaImageObjectFitPolyfillExtension get(UI ui) {
    CubaImageObjectFitPolyfillExtension extension = null;

    // Search singleton extension
    for (Extension uiExtension : ui.getExtensions()) {
        if (uiExtension instanceof CubaImageObjectFitPolyfillExtension) {
            extension = (CubaImageObjectFitPolyfillExtension) uiExtension;
            break;
        }
    }

    // Create new extension if not found
    if (extension == null) {
        extension = new CubaImageObjectFitPolyfillExtension();
        extension.extend(ui);
    }

    return extension;
}
 
Example #2
Source File: MGrid.java    From viritin with Apache License 2.0 6 votes vote down vote up
/**
 * Manually forces refresh of the row that represents given entity.
 * ListContainer backing MGrid/MTable don't support property change
 * listeners (to save memory and CPU cycles). In some case with Grid, if you
 * know only certain row(s) are changed, you can make a smaller client side
 * change by refreshing rows with this method, instead of refreshing the
 * whole Grid (e.g. by re-assigning the bean list).
 * <p>
 * This method is automatically called if you use "editor row".
 *
 * @param bean the bean whose row should be refreshed.
 */
public void refreshRow(T bean) {
    Collection<Extension> extensions = getExtensions();
    for (Extension extension : extensions) {
        // Calling with reflection for 7.6-7.5 compatibility
        if (extension.getClass().getName().contains(
                "RpcDataProviderExtension")) {
            try {
                Method method = extension.getClass().getMethod(
                        "updateRowData", Object.class);
                method.invoke(extension, bean);
                break;
            } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
                Logger.getLogger(MGrid.class.getName()).
                        log(Level.SEVERE, null, ex);
            }
        }
    }
}
 
Example #3
Source File: MGrid.java    From viritin with Apache License 2.0 6 votes vote down vote up
/**
 * Manually forces refresh of all visible rows. ListContainer backing
 * MGrid/MTable don't support property change listeners (to save memory and
 * CPU cycles). This method explicitly forces Grid's row cache invalidation.
 */
public void refreshVisibleRows() {
    Collection<Extension> extensions = getExtensions();
    for (Extension extension : extensions) {
        // Calling with reflection for 7.6-7.5 compatibility
        if (extension.getClass().getName().contains(
                "RpcDataProviderExtension")) {
            try {
                Method method = extension.getClass().getMethod(
                        "refreshCache");
                method.invoke(extension);
                break;
            } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
                Logger.getLogger(MGrid.class.getName()).
                        log(Level.SEVERE, null, ex);
            }
        }
    }
}
 
Example #4
Source File: HtmlAttributesExtension.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static HtmlAttributesExtension get(Component component) {
    for (Extension e : component.getExtensions()) {
        if (e instanceof HtmlAttributesExtension) {
            return (HtmlAttributesExtension) e;
        }
    }
    return new HtmlAttributesExtension((AbstractClientConnector) component);
}
 
Example #5
Source File: VaadinUI.java    From jpa-invoicer with The Unlicense 5 votes vote down vote up
protected void workaroundForFirefoxIssue(boolean initial) {
    if (initial && Page.getCurrent().getWebBrowser().getBrowserApplication().
            contains("Firefox")) {
        // Responsive, FF, cross site is currently broken :-(
        Extension r = null;
        for (Extension ext : getExtensions()) {
            if (ext instanceof Responsive) {
                r = ext;
            }
        }
        removeExtension(r);
    }
}
 
Example #6
Source File: ElementIntegration.java    From serverside-elements with Apache License 2.0 5 votes vote down vote up
public static Root getRoot(AbstractComponent target) {
    Optional<Extension> existing = target.getExtensions().stream()
            .filter(e -> e.getClass() == ElementIntegration.class)
            .findFirst();
    ElementIntegration integration = existing.isPresent() ? (ElementIntegration) existing
            .get() : new ElementIntegration(target);

    return integration.root;
}
 
Example #7
Source File: ContextMenu.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
protected void addExtension(Extension extension) {
    ContextMenu.this.addExtension(extension);
}
 
Example #8
Source File: ContextMenu.java    From context-menu with Apache License 2.0 4 votes vote down vote up
@Override
protected void addExtension(Extension extension) {
    ContextMenu.this.addExtension(extension);
}