private static void maybeInitializeScrollHandlers() { if (GWT.isClient() && !scrollHandlersInitialized) { impl.initWindowScrollHandler(); scrollHandlersInitialized = true; } }
private static void maybeInitializeCloseHandlers() { if (GWT.isClient() && !closeHandlersInitialized) { impl.initWindowCloseHandler(); closeHandlersInitialized = true; } }
private static void maybeInitializeResizeHandlers() { if (GWT.isClient() && !resizeHandlersInitialized) { impl.initWindowResizeHandler(); resizeHandlersInitialized = true; } }
/** * Creates the loader stored as {@link #BROWSER_LOADER}. * * @returns {@code null} if not in GWT client code, where * {@link GWT#create(Class)} cannot be used, or a fragment loader for * the user's application otherwise. */ private static AsyncFragmentLoader makeBrowserLoader(int numFragments, int initialLoad[]) { if (GWT.isClient()) { return new AsyncFragmentLoader(numFragments, initialLoad, (LoadingStrategy) GWT.create(LoadingStrategy.class), (Logger) GWT.create(Logger.class), (OnSuccessExecutor) GWT.create(OnSuccessExecutor.class)); } else { return null; } }
public void configureClientSideLogging() { assert GWT.isClient(); root = Logger.getLogger(""); // In DevMode, this root logger will have a parent and we do not want this // root logger to pass messages to it's parent, so we set // useParentHandlers to false here. root.setUseParentHandlers(false); setLevels(root); setDefaultHandlers(root); }
/** * Calls a native JS <code>equals</code> method if any, otherwise * returns <code>true</code> if the objects are JavaScript identical * (triple-equals). */ @Override public final boolean equals(Object other) { if (!GWT.isClient()) { return super.equals(other); } return hasEquals(this) ? callEquals(this, other) : super.equals(other); }
/** * Calls a native JS <code>hashCode</code> method if any, otherwise * uses a monotonically increasing counter to assign a hash code to the * underlying JavaScript object. Do not call this method on non-modifiable * JavaScript objects. * * @return the hash code of the object */ @Override public final int hashCode() { if (!GWT.isClient()) { return super.hashCode(); } return hasHashCode(this) ? callHashCode(this) : super.hashCode(); };
private static void reportUncaughtException( Throwable e, boolean reportSwallowedExceptionToBrowser) { if (Impl.uncaughtExceptionHandlerForTest != null) { Impl.uncaughtExceptionHandlerForTest.onUncaughtException(e); } UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler(); if (handler != null) { if (handler == Impl.uncaughtExceptionHandlerForTest) { return; // Already reported so we're done. } // TODO(goktug): Handler might throw an exception but catching and reporting it to browser // here breaks assumptions of some existing hybrid apps that uses UCE for exception // conversion. We don't have an alternative functionality (yet) and it is too risky to include // the change in the release at last minute. handler.onUncaughtException(e); return; // Done. } // Make sure that the exception is not swallowed if (GWT.isClient() && reportSwallowedExceptionToBrowser) { reportToBrowser(e); } else { System.err.print("Uncaught exception "); e.printStackTrace(System.err); } }
/** * IE6 does not allow direct access to event handlers on the parent window, * so we must embed a script in the parent window that will set the event * handlers in the correct context. * * @param initFunc the string representation of the init function * @param cmd the command to execute the init function */ private void initHandler(String initFunc, ScheduledCommand cmd) { if (GWT.isClient()) { // Embed the init script on the page ScriptElement scriptElem = Document.get().createScriptElement(initFunc); Document.get().getBody().appendChild(scriptElem); // Initialize the handler cmd.execute(); // Remove the script element Document.get().getBody().removeChild(scriptElem); } }
private Logger getLogger() { if (GWT.isClient() && LogConfiguration.loggingIsEnabled() && logger == null) { logger = Logger.getLogger(AbstractAsyncCallback.class.getName()); } return logger; }
private Logger getLogger() { if (GWT.isClient() && LogConfiguration.loggingIsEnabled() && logger == null) { logger = Logger.getLogger(AbstractRequestCallback.class.getName()); } return logger; }
private Logger getLogger() { if (GWT.isClient() && LogConfiguration.loggingIsEnabled() && logger == null) { logger = Logger.getLogger(AbstractRequestCallback.class.getName()); } return logger; }
private void doRemove(CacheKey key, String scope) { if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) { Logger.getLogger(DefaultQueueableCacheStorage.class.getName()) .finer("removing cache-key " + key + " from scope \"" + scope + "\""); } HashMap<CacheKey, Response> scoped = cache.get(scope); if (null != scoped) { scoped.remove(key); } } }
private Logger getLogger() { if (GWT.isClient() && LogConfiguration.loggingIsEnabled() && logger == null) { logger = Logger.getLogger(Method.class.getName()); } return logger; }
private void doRemove(CacheKey key, String scope) { if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) { Logger.getLogger(DefaultQueueableCacheStorage.class.getName()) .finer("removing cache-key " + key + " from scope \"" + scope + "\""); } HashMap<CacheKey, Response> scoped = cache.get(scope); if (null != scoped) { scoped.remove(key); } } }
@Override public void onResponseReceived(Request request, Response response) { if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) { Logger.getLogger(CachingCallbackFilter.class.getName()) .finer("call " + removedCallbacks.size() + " more queued callbacks for " + ck); } // call all callbacks found in cache for (RequestCallback cb : removedCallbacks) { cb.onResponseReceived(request, response); } }
@Override public void run() { try { method.builder.send(); } catch (RequestException ex) { if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) { Logger.getLogger(RetryingFilterawareRequestCallback.class.getName()) .severe(ex.getMessage()); } } } };
private void renderNeeded() { if (!GWT.isClient() || view.isAttached()) { // in unit tests, render should be cheap render(); } else { // Wait until we're attached needsRender = true; } }
protected void cacheResult(Method method, Response response) { CacheKey cacheKey = cacheKey(method.builder); if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) { Logger.getLogger(CachingCallbackFilter.class.getName()).finer("cache to " + cacheKey + ": " + response); } cache.putResult(cacheKey, response, getCacheDomains(method)); }
/** * Setup clonable elements. */ void initializeClonableElements() { if (GWT.isClient()) { // Create the base table element that will be cloned. BASE_INTERNAL_ELEM = DOM.createTable(); Element contentElem = DOM.createDiv(); Element tbody = DOM.createTBody(), tr = DOM.createTR(); Element tdImg = DOM.createTD(), tdContent = DOM.createTD(); DOM.appendChild(BASE_INTERNAL_ELEM, tbody); DOM.appendChild(tbody, tr); DOM.appendChild(tr, tdImg); DOM.appendChild(tr, tdContent); tdImg.getStyle().setProperty("verticalAlign", "middle"); tdContent.getStyle().setProperty("verticalAlign", "middle"); DOM.appendChild(tdContent, contentElem); contentElem.getStyle().setProperty("display", "inline"); setStyleName(contentElem, "gwt-TreeItem"); BASE_INTERNAL_ELEM.getStyle().setProperty("whiteSpace", "nowrap"); // Create the base element that will be cloned BASE_BARE_ELEM = DOM.createDiv(); // Simulates padding from table element. BASE_BARE_ELEM.getStyle().setProperty("padding", "3px"); DOM.appendChild(BASE_BARE_ELEM, contentElem); Roles.getTreeitemRole().set(contentElem); } } }