Java Code Examples for com.google.gwt.core.client.GWT#isScript()

The following examples show how to use com.google.gwt.core.client.GWT#isScript() . 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: JTSWebAppEntry.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void onModuleLoad() {
	sLogger.info("Module loading");

	if (GWT.isScript()) {
		GWT.setUncaughtExceptionHandler(this);

		Scheduler.get().scheduleDeferred(new ScheduledCommand() {
			
			@Override
			public void execute() {
				onLoad();
			}
		});
	} else {
		onLoad();
	}
}
 
Example 2
Source File: ClientJsonCodec.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for encoding any "primitive" value that is directly supported in
 * JSON. Supported values types are {@link String}, {@link Number},
 * {@link Boolean}, {@link JsonValue}. <code>null</code> is also supported.
 *
 * @param value
 *            the value to encode
 * @return the value encoded as JSON
 */
public static JsonValue encodeWithoutTypeInfo(Object value) {
    if (value == null) {
        // undefined shouln't go as undefined, it should be encoded as null
        return Json.createNull();
    } else if (GWT.isScript()) {
        return WidgetUtil.crazyJsoCast(value);
    } else {
        if (value instanceof String) {
            return Json.create((String) value);
        } else if (value instanceof Number) {
            return Json.create(((Number) value).doubleValue());
        } else if (value instanceof Boolean) {
            return Json.create(((Boolean) value).booleanValue());
        } else if (value instanceof JsonValue) {
            return (JsonValue) value;
        }
        throw new IllegalArgumentException(
                "Can't encode" + value.getClass() + " to json");
    }
}
 
Example 3
Source File: Footer.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Inject
public Footer(PlaceManager placeManager, ProductConfig prodConfig, BootstrapContext context, Dispatcher circuit) {

    this.placeManager = placeManager;
    this.productConfig = prodConfig;
    this.context = context;

    if(!GWT.isScript()) {
        diag = new DiagnosticsView();
        diagWidget = diag.asWidget();
        circuit.addDiagnostics(diag);
    }

    if(!GWT.isScript())
        this.rbacView = new RBACContextView();
}
 
Example 4
Source File: FastArrayInteger.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public void push(int value) {
	if(GWT.isScript()) {
		stackNative.push(value);
	} else {
		stackJava.add(value);
	}
}
 
Example 5
Source File: FastArrayNumber.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public double get(int index) {
	if(GWT.isScript()) {
		return stackNative.get(index);
	} else {
		return stackJava.get(index);
	}
}
 
Example 6
Source File: FastArrayNumber.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public double[] reinterpretCast() {
	if(GWT.isScript()) {
		return reinterpretCast(stackNative);
	} else {
		double[] ret = new double[stackJava.size()];
		for (int i = 0; i < stackJava.size(); i++) {
			ret[i] = stackJava.get(i);
		}
		return ret;
	}
}
 
Example 7
Source File: FastArrayString.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public String[] reinterpretCast() {
	if(GWT.isScript()) {
		return reinterpretCast(stackNative);
	} else {
		String[] ret = new String[stackJava.size()];
		for (int i = 0; i < stackJava.size(); i++) {
			ret[i] = stackJava.get(i);
		}
		return ret;
	}
}
 
Example 8
Source File: StageZero.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
protected final void create(Accessor<StageZero> whenReady) {
  onStageInit();
  // TODO: enable webdriver hook.
  GWT.setUncaughtExceptionHandler(createUncaughtExceptionHandler());
  if (GWT.isScript()) {
    CollectionUtils.setDefaultCollectionFactory(new JsoCollectionFactory());
  }
  onStageLoaded();
  whenReady.use(this);
}
 
Example 9
Source File: AnalyticsProvider.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public GoogleAnalytics get() {

    GoogleAnalytics analytics;


    if(!Preferences.has(Preferences.Key.ANALYTICS)) // inital setup
    {
        // in Community we enable analytics by default
        boolean isCommunity = ProductConfig.Profile.COMMUNITY.equals(prodConfig.getProfile());

        if (isCommunity)
            Preferences.set(Preferences.Key.ANALYTICS, "true");
        else
            Preferences.set(Preferences.Key.ANALYTICS, "false");
    }

    // check settings if enabled
    boolean isEnabledInPreferences = Preferences.has(Preferences.Key.ANALYTICS) && Preferences
            .get(Preferences.Key.ANALYTICS).equals("true");

    // Google Analytics is an opt-in for the product and an opt-out for the community version
    // in web mode it's always enabled (disabled during development)
    boolean isWebMode = GWT.isScript();
    if (isWebMode) {
        analytics = isEnabledInPreferences ? new CustomAnalyticsImpl() : NOOP;
    } else {
        analytics = NOOP;
    }

    System.out.println("Google analytics: Using " + (analytics == NOOP ? "stub" : "real") + " implementation");

    return analytics;
}
 
Example 10
Source File: StageZero.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
protected final void create(Accessor<StageZero> whenReady) {
  onStageInit();
  // TODO: enable webdriver hook.
  //GWT.setUncaughtExceptionHandler(createUncaughtExceptionHandler());
  if (GWT.isScript()) {
    CollectionUtils.setDefaultCollectionFactory(new JsoCollectionFactory());
  }
  onStageLoaded();
  whenReady.use(this);
}
 
Example 11
Source File: StageZero.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
protected final void create(Accessor<StageZero> whenReady) {
  onStageInit();
  // TODO: enable webdriver hook.
  if (GWT.isScript()) {
    CollectionUtils.setDefaultCollectionFactory(new JsoCollectionFactory());
  }
  onStageLoaded();
  whenReady.use(this);
}
 
Example 12
Source File: FastArrayInteger.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public int get(int index) {
	if(GWT.isScript()) {
		return stackNative.get(index);
	} else {
		return stackJava.get(index);
	}
}
 
Example 13
Source File: FastArrayShort.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public short[] reinterpretCast() {
	if(GWT.isScript()) {
		return reinterpretCast(stackNative);
	} else {
		short[] ret = new short[stackJava.size()];
		for (int i = 0; i < stackJava.size(); i++) {
			ret[i] = stackJava.get(i);
		}
		return ret;
	}
}
 
Example 14
Source File: JsArray.java    From flow with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the item at the given index. This is corresponding to
 * <code>return array[index]</code> in JavaScript.
 *
 * @param index
 *            the index to get
 * @return the item at the given index
 */
@JsOverlay
public final T get(int index) {
    if (GWT.isScript()) {
        return JsniHelper.getValueNative(this, index);
    } else {
        return ((JreJsArray<T>) this).doGet(index);
    }
}
 
Example 15
Source File: FastArrayShort.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public void set(int index, short value) {
	if(GWT.isScript()) {
		stackNative.set(index, value);
	} else {
		stackJava.set(index, value);
	}
}
 
Example 16
Source File: LoadGoogleViz.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(Control<BootstrapContext> control) {
    // GWT vis is only used by MBUI tools. These are available in dev mode only
    if (!GWT.isScript()) {
        VisualizationUtils.loadVisualizationApi(() -> {
                    System.out.println("Loaded Google Vizualization API");
                }, LineChart.PACKAGE, OrgChart.PACKAGE
        );
    }
    // viz can be loaded in background ...
    control.proceed();
}
 
Example 17
Source File: FastArrayString.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public String get(int index) {
	if(GWT.isScript()) {
		return stackNative.get(index);
	} else {
		return stackJava.get(index);
	}
}
 
Example 18
Source File: ModelNode.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static boolean hasNativeBase64Support() {

        //TODO: there is a problem with the hosted call to nativeBase64()
        return !GWT.isScript() ?  false : nativeBase64();
    }
 
Example 19
Source File: JsArray.java    From flow with Apache License 2.0 3 votes vote down vote up
/**
 * Removes and adds a number of items at the given index.
 *
 * @param index
 *            the index at which do do the operation
 * @param remove
 *            the number of items to remove
 * @param add
 *            new items to add
 * @return an array of removed items
 */
@JsOverlay
public final JsArray<T> spliceArray(int index, int remove,
        JsArray<? extends T> add) {
    if (GWT.isScript()) {
        return JsniHelper.spliceArray(this, index, remove, add);
    } else {
        return ((JreJsArray<T>) this).doSpliceArray(index, remove, add);
    }
}
 
Example 20
Source File: JsCollections.java    From flow with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new JavaScript WeakMap.
 *
 * @param <K>
 *            the key type
 * @param <V>
 *            the value type
 * @return a new JS weak map instance
 */
public static <K, V> JsWeakMap<K, V> weakMap() {
    if (GWT.isScript()) {
        checkJunitPolyfillStatus();
        return createNativeWeakMap();
    }
    return new JreJsWeakMap<>();
}