Java 类com.google.gwt.core.client.JavaScriptObject 实例源码

项目:empiria.player    文件:ExternalInteractionStateProviderTest.java   
@Test
public void shouldReturnEncodedState() throws Exception {
    // GIVEN
    JavaScriptObject givenStateObject = mock(JavaScriptObject.class);
    JSONArray encodedState = mock(JSONArray.class);

    when(externalApiProvider.getExternalApi().getStateFromExternal()).thenReturn(givenStateObject);
    when(stateEncoder.encodeState(givenStateObject)).thenReturn(encodedState);

    // WHEN
    JSONArray result = testObj.getState();

    // THEN
    assertThat(result).isEqualTo(encodedState);
    verify(externalStateSaver).setExternalState(givenStateObject);
}
项目:empiria.player    文件:ModuleJsSocketFactory.java   
public static JavaScriptObject createSocketObject(Object module) {
    JavaScriptObject jso = JavaScriptObject.createObject();

    jso = addObjectFunctions(jso, module.getClass().getName());

    if (module instanceof Lockable) {
        jso = addLockableFunctions(jso, module);
    }

    if (module instanceof Resetable) {
        jso = addResetableFunctions(jso, module);
    }

    if (module instanceof Activity) {
        jso = addActivityFunctions(jso, module);
    }

    if (module instanceof IUniqueModule) {
        jso = addUniqueFunctions(jso, module);
    }

    return jso;
}
项目:unitimes    文件:Lookup.java   
public static void peopleLookup(String query, final JavaScriptObject callback, String options) {
    final Lookup lookup = new Lookup();
    if (query != null && !query.trim().isEmpty())
        lookup.setQuery(query);
    lookup.addValueChangeHandler(new ValueChangeHandler<PersonInterface>() {
        @Override
        public void onValueChange(ValueChangeEvent<PersonInterface> event) {
            if (event.getValue() != null)
                lookup.fireCallback(callback,
                    event.getValue().getId(),
                    event.getValue().getFirstName(),
                    event.getValue().getMiddleName(),
                    event.getValue().getLastName(),
                    event.getValue().getEmail(),
                    event.getValue().getPhone(),
                    event.getValue().getAcademicTitle(),
                    event.getValue().getName());
        }
    });
    lookup.setOptions(options);
    lookup.center();
}
项目:empiria.player    文件:FlowActivityEvent.java   
public static FlowActivityEvent fromJsObject(JavaScriptObject jsObject) {
    String currTypeString = getTypeJs(jsObject);
    final String groupIdentifierString = getGroupIdentifierJs(jsObject); // NOPMD
    if (currTypeString != null) {
        currTypeString = currTypeString.trim().toUpperCase();
        for (FlowActivityEventType currType : FlowActivityEventType.values()) {
            if (currType.toString().equals(currTypeString)) {
                return new FlowActivityEvent(currType, new GroupIdentifier() { // NOPMD

                    @Override
                    public String getIdentifier() {
                        return groupIdentifierString;
                    }
                });
            }
        }
    }
    return null;
}
项目:empiria.player    文件:ExternalStateEncoderGWTTestCase.java   
public void testShouldGetStateObject() {
    // given
    JavaScriptObject state = JavaScriptObject.createObject();
    JSONArray stateArray = new JSONArray();
    stateArray.set(0, new JSONObject(state));

    JSONObject stateObject = new JSONObject();
    stateObject.put("STATE", stateArray);

    JSONArray jsonArray = new JSONArray();
    jsonArray.set(0, stateObject);

    // when
    JavaScriptObject result = testObj.decodeState(jsonArray);

    // then
    assertEquals(result, state);
}
项目:empiria.player    文件:TextEditorDesktopOptions.java   
private native final JavaScriptObject getDesktopOptions() /*-{
    var options = {
        link: false,
        indent: false,
        outdent: false,
        unlink: false,
        remove: false,
        source: false,
        rule: false
    };
    return options;
}-*/;
项目:Charba    文件:Plugins.java   
/**
 * Returns the plugin options, if exist.
 * @param pluginId plugin id.
 * @return java script object used to configure the plugin or <code>null</code> if not exist.
 * @throws InvalidPluginIdException occurs if the plugin id is invalid.
 */
public JavaScriptObject getOptions(String pluginId) throws InvalidPluginIdException{
    // checks the plugin id
    PluginIdChecker.check(pluginId);
    // returns the configuration creating a key by plugin id.
    return getValue(new StandardKey(pluginId));
}
项目:empiria.player    文件:PlayerCoreApiExtension.java   
private native int callImportInitialItemIndex(JavaScriptObject playerJsObject)/*-{
    var itemIndex = -1;
    if (typeof playerJsObject.importInitialItemIndex == 'function') {
        var importedIndex = playerJsObject.importInitialItemIndex();
        if (!isNaN(importedIndex)) {
            itemIndex = parseInt(importedIndex);
        }
    }

    return itemIndex;

}-*/;
项目:empiria.player    文件:ModuleJsSocketFactory.java   
private static native JavaScriptObject addObjectFunctions(JavaScriptObject jso, String className)/*-{
    var instanceClassName = className;
    jso.getClassName = function () {
        return instanceClassName;
    }
    return jso;
}-*/;
项目:empiria.player    文件:TextActionProcessor.java   
@Override
public void processSingleAction(FeedbackAction action, FeedbackMark mark) {
    ShowTextAction textAction = (ShowTextAction) action;
    feedbackCounter.add(textAction);

    Element element = textAction.getContent().getValue();
    Widget widget = inlineBodyGenerator.generateInlineBody(element);
    feedbackPresenter.setFeedbackContent(widget, mark);

    JavaScriptObject mathJaxCallback = createCallback(textAction);
    mathJaxNative.renderMath(mathJaxCallback);
}
项目:empiria.player    文件:FlowRequest.java   
@Override
public JavaScriptObject toJsObject() {
    String giString = "";
    if (getGroupIdentifier() != null)
        giString = getGroupIdentifier().getIdentifier();
    return createRequestJsObject(getName(), giString);
}
项目:empiria.player    文件:JsPageInterferenceSocketUserExtension.java   
private native JavaScriptObject createPageInterferenceSocketJs(JavaScriptObject socketJs)/*-{
    var instance = this;
    var socket = [];
    var ais = socketJs;
    socket.getPageInterferenceSocket = function () {
        return ais;
    }
    return socket;
}-*/;
项目:empiria.player    文件:PlayerCoreApiExtension.java   
private void setOptions() {
    JavaScriptObject flowOptionsJs = callImportFlowOptionsJs(playerJsObject);

    if (flowOptionsJs != null) {
        FlowOptions flowOptions = FlowOptions.fromJsObject(flowOptionsJs);
        deliveryEngineSocket.setFlowOptions(flowOptions);
    }

    JavaScriptObject displayOptionsJs = callImportDisplayOptionsJs(playerJsObject);

    if (displayOptionsJs != null) {
        DisplayOptions displayOptions = DisplayOptions.fromJsObject(displayOptionsJs);
        deliveryEngineSocket.setDisplayOptions(displayOptions);
    }
}
项目:Charba    文件:Plugins.java   
/**
 * Sets the plugin options. If passed otpions is null, the configuration of plugin will be removed.
 * @param pluginId plugin id.
 * @param options java script object used to configure the plugin. Pass <code>null</code> to remove the configuration if exist.
 * @throws InvalidPluginIdException occurs if the plugin id is invalid.
 */
public void setOptions(String pluginId, JavaScriptObject options) throws InvalidPluginIdException {
    // checks the plugin id
    PluginIdChecker.check(pluginId);
    // creates a key using plugin ID
    Key key = new StandardKey(pluginId);
    // if null, removes the configuration
    if (options == null){
        // removes configuration if exists
        removeIfExists(key);
    } else {
        // stores configuration
        setValue(key, options);
    }
}
项目:empiria.player    文件:DeliveryEngineGWTTestCase.java   
public void testDeliveryEventsPageSwitch() {
    types = typesPageSwitch;
    PlayerGinjector injector = PlayerGinjectorFactory.getNewPlayerGinjectorForGWTTestCase();
    de = injector.getDeliveryEngine();
    de.init(JavaScriptObject.createObject());
    Extension ext = new MockDeliveryEventsListenerExtension();
    de.setFlowOptions(new FlowOptions(true, false, PageItemsDisplayMode.ONE, ActivityMode.NORMAL));
    de.loadExtension(ext);
    de.load(getAssessmentXMLData(), getItemXMLDatas());
}
项目:empiria.player    文件:PageChangedEventGWTTestCase.java   
public void testShouldSerializeEventWithTypeAndPageIndex() {
    // given
    PageChangedEvent testObj = new PageChangedEvent(EXPECTED_PAGE_INDEX);

    // when
    JavaScriptObject actual = testObj.getJSONObject();
    JSONObject actualJSON = new JSONObject(actual);

    // then
    double actualPage = actualJSON.get("payload").isObject().get("new_page").isNumber().doubleValue();
    assertEquals(actualPage, EXPECTED_PAGE_INDEX, DELTA);

    String actualEventType = actualJSON.get("type").isString().stringValue();
    assertEquals(actualEventType, "page_changed");
}
项目:empiria.player    文件:ConnectionModuleViewImplTest.java   
private CssHelper createCssHelperMock() {
    CssHelper cssHelper = spy(new CssHelper());
    Style style = mock(Style.class);
    doReturn("none").when(style).getProperty(Matchers.anyString());
    doReturn(style).when(cssHelper).getComputedStyle(Matchers.any(JavaScriptObject.class));
    return cssHelper;
}
项目:empiria.player    文件:SoundJsNative.java   
private native void onComplete(JavaScriptObject soundInstance)/*-{
    if (typeof soundInstance.onComplete == 'function') {
        soundInstance.onComplete(soundInstance);
    }
}-*/;
项目:empiria.player    文件:JsFlowDataSocketUserExtension.java   
private JavaScriptObject getFlowOptionsJs() {
    return supplier.getFlowOptions().toJsObject();
}
项目:empiria.player    文件:JsStatefulExtension.java   
private native String getStateJs(JavaScriptObject extension)/*-{
    if (typeof extension.getStateString == 'function') {
        return extension.getStateString();
    }
    return null;
}-*/;
项目:Charba    文件:AbstractPlugin.java   
@Override
public boolean onBeforeEvent(AbstractChart<?, ?> chart, ChartNativeEvent event, JavaScriptObject options){
    return true;
}
项目:empiria.player    文件:SimulationController.java   
public void resumeAnimation(JavaScriptObject context) {
    callMethod(context, METHOD_NAME_RESUME_ANIMATION);
}
项目:empiria.player    文件:SimulationController.java   
public void onWindowResized(JavaScriptObject context) {
    callMethod(context, METHOD_NAME_WINDOW_RESIZED);
}
项目:empiria.player    文件:SimulationController.java   
private void callMethod(JavaScriptObject context, String methodName) {
    methodInvocator.callMethod(context, methodName);
}
项目:empiria.player    文件:JSArrayUtils.java   
public static native JavaScriptObject fillArray(JavaScriptObject array, String index, boolean item)/*-{
    array[index] = item;
    return array;
}-*/;
项目:empiria.player    文件:JsBonusExtension.java   
private final native String getBonusIdNative(JavaScriptObject extensionJsObject)/*-{
    return extensionJsObject.getBonusId();
}-*/;
项目:empiria.player    文件:TextEditorDesktopOptions.java   
@Override
public JavaScriptObject getOptions() {
    return getDesktopOptions();
}
项目:empiria.player    文件:JsSessionDataSocketUserExtension.java   
private native void setSessionDataSocketJs(JavaScriptObject extension, JavaScriptObject socket)/*-{
    if (typeof extension.setSessionDataSocket == 'function') {
        extension.setSessionDataSocket(socket);
    }
}-*/;
项目:Charba    文件:AbstractPlugin.java   
@Override
public void onBeforeInit(AbstractChart<?, ?> chart, JavaScriptObject options){
}
项目:empiria.player    文件:IdentificationModule.java   
@Override
public JavaScriptObject getJsSocket() {
    return ModuleJsSocketFactory.createSocketObject(this);
}
项目:empiria.player    文件:MathJaxNative.java   
public void renderMath(JavaScriptObject callback) {
    renderMathNative(callback);
}