Java Code Examples for com.google.gwt.core.client.JavaScriptObject#createObject()
The following examples show how to use
com.google.gwt.core.client.JavaScriptObject#createObject() .
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: DragAndDropUploader.java From document-management-system with GNU General Public License v2.0 | 6 votes |
/** * Add an element to queue. */ public void addToQueue(File file, String name, String path) { if (cancelled) { // Folders continue reading but the user cancel the operation. This element must be cancelled also UploaderEvent event = new UploaderEvent(path + "/" + file.getFileName(), 1.0, "canceled.by.user"); uploadedFileCallback.onSuccess(event); } else if (currentElement == null) { // Only one item could be processed at same time and insertOrUpdateFile is not setting this var until some async calls currentElement = JavaScriptObject.createObject(); insertOrUpdateFile(file, name, path); } else { synchronized (queue) { queue.add(new UploaderQueueElement(file, name, path)); Main.get().mainPanel.topPanel.setDragAndDropPendingFilesToUpload(queue.size()); } } }
Example 2
Source File: GwtAtmoshperePushConnectionTest.java From flow with Apache License 2.0 | 6 votes |
public void testDicsonnect_disconnectUrlIsSameAsInConnect() { setUpAtmosphere(); registry.getApplicationConfiguration().setServiceUrl("context://foo"); registry.getApplicationConfiguration().setContextRootUrl("bar/"); AtmospherePushConnection connection = new AtmospherePushConnection( registry); String pushUri = getPushUri(); AtmosphereResponse response = (AtmosphereResponse) JavaScriptObject .createObject(); connection.onConnect(response); connection.disconnect(() -> { }); assertTrue(getUnsubscriveUri().startsWith("bar/")); assertEquals(pushUri, getUnsubscriveUri()); }
Example 3
Source File: ServerEventObject.java From flow with Apache License 2.0 | 5 votes |
/** * Gets or creates <code>element.$server</code> for the given element. * * @param element * the element to use * @return a reference to the <code>$server</code> object in the element */ public static ServerEventObject get(Element element) { ServerEventObject serverObject = getIfPresent(element); if (serverObject == null) { serverObject = (ServerEventObject) JavaScriptObject.createObject(); serverObject.initPromiseHandler(); WidgetUtil.setJsProperty(element, "$server", serverObject); } return serverObject; }
Example 4
Source File: GwtMessageHandlerTest.java From flow with Apache License 2.0 | 5 votes |
public void testMessageProcessing_dynamicDependencyIsHandledBeforeApplyingChangesToTree() { resetInternalEvents(); JavaScriptObject object = JavaScriptObject.createObject(); JsonObject obj = object.cast(); // make an empty changes list. It will initiate changes processing // anyway // Any changes processing should happen AFTER dependencies are loaded obj.put("changes", Json.createArray()); JsonArray array = Json.createArray(); // create a dependency JsonObject dep = Json.createObject(); dep.put(Dependency.KEY_TYPE, Dependency.Type.DYNAMIC_IMPORT.toString()); dep.put(Dependency.KEY_URL, "return new Promise(function(resolve){ " + "window.testEvents.push('test-dependency'); resolve(); });"); array.set(0, dep); obj.put(LoadMode.LAZY.toString(), array); handler.handleJSON(object.cast()); delayTestFinish(500); new Timer() { @Override public void run() { assertEquals("test-dependency", getInternalEvent(0)); assertEquals(StateTree.class.getName(), getInternalEvent(1)); finishTest(); } }.schedule(100); }
Example 5
Source File: GwtMessageHandlerTest.java From flow with Apache License 2.0 | 5 votes |
public void testForceHandleMessage_resyncIsRequested() { resetInternalEvents(); setResyncState(false); // given a max message suspension time of 200 ms registry.getApplicationConfiguration().setMaxMessageSuspendTimeout(200); // when two out-of-order messages happen JavaScriptObject object1 = JavaScriptObject.createObject(); JsonObject obj1 = object1.cast(); obj1.put("syncId", 1); handler.handleJSON(object1.cast()); JavaScriptObject object2 = JavaScriptObject.createObject(); JsonObject obj2 = object2.cast(); obj2.put("syncId", 3); handler.handleJSON(object2.cast()); // then a resync message is sent within 300 ms delayTestFinish(500); new Timer() { @Override public void run() { assertTrue(getResyncState()); finishTest(); } }.schedule(300); }
Example 6
Source File: StateMap.java From swellrt with Apache License 2.0 | 5 votes |
/** * Convert this into a serializable JavaScriptObject. Eliminates the ":" * key prefixes. * * @return The JavaScriptObject of the valid keys. */ public final JavaScriptObject asJavaScriptObject() { final JavaScriptObject jso = JavaScriptObject.createObject(); each(new Each() { @Override public void apply(String key, String value) { putKeyValue(jso, key, value); } }); return jso; }
Example 7
Source File: StateMap.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Convert this into a serializable JavaScriptObject. Eliminates the ":" * key prefixes. * * @return The JavaScriptObject of the valid keys. */ public final JavaScriptObject asJavaScriptObject() { final JavaScriptObject jso = JavaScriptObject.createObject(); each(new Each() { @Override public void apply(String key, String value) { putKeyValue(jso, key, value); } }); return jso; }
Example 8
Source File: SliderBase.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
@Override protected void onLoad() { super.onLoad(); final JavaScriptObject options = JavaScriptObject.createObject(); if (formatterCallback != null) { setFormatterOption(options); } sliderNamespaceAvailable = isSliderNamespaceAvailable(); initSlider(getElement(), options); bindSliderEvents(getElement()); }
Example 9
Source File: GwtDomApiTest.java From flow with Apache License 2.0 | 4 votes |
private void startMessageHandling() { JavaScriptObject message = JavaScriptObject.createObject(); registry.getMessageHandler().handleMessage((ValueMap) message); }
Example 10
Source File: GwtMessageHandlerTest.java From flow with Apache License 2.0 | 4 votes |
public void testMessageProcessing_moduleDependencyIsHandledBeforeApplyingChangesToTree() { resetInternalEvents(); JavaScriptObject object = JavaScriptObject.createObject(); JsonObject obj = object.cast(); // make an empty changes list. It will initiate changes processing // anyway // Any changes processing should happen AFTER dependencies are loaded obj.put("changes", Json.createArray()); JsonArray array = Json.createArray(); // create a dependency JsonObject dep = Json.createObject(); dep.put(Dependency.KEY_URL, "foo"); dep.put(Dependency.KEY_TYPE, Dependency.Type.JS_MODULE.toString()); array.set(0, dep); obj.put(LoadMode.EAGER.toString(), array); handler.handleJSON(object.cast()); delayTestFinish(500); new Timer() { @Override public void run() { assertTrue(getResourceLoader().scriptUrls.contains("foo")); EventsOrder eventsOrder = registry.get(EventsOrder.class); assertTrue(eventsOrder.sources.size() >= 2); // the first one is resource loaded which means dependency // processing assertEquals(ResourceLoader.class.getName(), eventsOrder.sources.get(0)); // the second one is applying changes to StatTree assertEquals(StateTree.class.getName(), eventsOrder.sources.get(1)); finishTest(); } }.schedule(100); }
Example 11
Source File: InterceptorsActivity.java From requestor with Apache License 2.0 | 4 votes |
private JavaScriptObject getMessageJson(String message) { JavaScriptObject json = JavaScriptObject.createObject(); Overlays.setString(json, "message", message); return json; }
Example 12
Source File: JsonRecordWriter.java From requestor with Apache License 2.0 | 4 votes |
static JsonRecordWriter create() { return (JsonRecordWriter) JavaScriptObject.createObject(); }