public static CubaAmchartsResponsiveIntegration get(UI ui) { CubaAmchartsResponsiveIntegration optioner = null; // Search singleton optioner for (Extension extension : ui.getExtensions()) { if (extension instanceof CubaAmchartsResponsiveIntegration) { optioner = (CubaAmchartsResponsiveIntegration) extension; break; } } // Create new optioner if not found if (optioner == null) { optioner = new CubaAmchartsResponsiveIntegration(); optioner.extend(ui); } return optioner; }
public static CubaAmchartsIntegration get(UI ui) { CubaAmchartsIntegration optioner = null; // Search singleton optioner for (Extension extension : ui.getExtensions()) { if (extension instanceof CubaAmchartsIntegration) { optioner = (CubaAmchartsIntegration) extension; break; } } // Create new optioner if not found if (optioner == null) { optioner = new CubaAmchartsIntegration(); optioner.extend(ui); } return optioner; }
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; } }
/** * Returns a local storage proxy bound to the given UI. * * @param ui * the UI to bind to. * @return A LocalStorage extension bound to the given UI. If an extension * is not yet applied, a new one is created and applied to the UI. */ public static LocalStorage get(UI ui) { if (ui == null) { throw new IllegalArgumentException("A UI must be provided"); } LocalStorage locator = null; // Do we already have an extension attached? for (Extension e : ui.getExtensions()) { if (e instanceof LocalStorage) { locator = (LocalStorage) e; } } // Attach if none found. if (locator == null) { locator = new LocalStorage(); locator.extend(UI.getCurrent()); } return locator; }
/** * Detects the current geographic location of the client. The detection * happens asynchronously and the position is reported to the callback given * in the callback argument. Note that this only checks the position once, * you need to call this method multiple times if you want to update the * location as the client moves. * * @param callback * The {@link PositionCallback} instance that is called when the * position is available. */ public static void detect(PositionCallback callback) { Geolocator locator = null; // Do we already have a Geolocator attached? for (Extension e : UI.getCurrent().getExtensions()) { if (e instanceof Geolocator) { locator = (Geolocator) e; } } // Attach a Geolocator if none found. if (locator == null) { locator = new Geolocator(); locator.extend(UI.getCurrent()); } locator.detectCurrentPosition(callback); }