Java Code Examples for com.google.gwt.core.client.JsArray#push()
The following examples show how to use
com.google.gwt.core.client.JsArray#push() .
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: DomHelper.java From swellrt with Apache License 2.0 | 6 votes |
/** * Gets a list of descendants of e that match the given class name. * * If the browser has the native method, that will be called. Otherwise, it * traverses descendents of the given element and returns the list of elements * with matching classname. * * @param e * @param className */ public static NodeList<Element> getElementsByClassName(Element e, String className) { if (QuirksConstants.SUPPORTS_GET_ELEMENTS_BY_CLASSNAME) { return getElementsByClassNameNative(e, className); } else { NodeList<Element> all = e.getElementsByTagName("*"); if (all == null) { return null; } JsArray<Element> ret = JavaScriptObject.createArray().cast(); for (int i = 0; i < all.getLength(); ++i) { Element item = all.getItem(i); if (className.equals(item.getClassName())) { ret.push(item); } } return ret.cast(); } }
Example 2
Source File: SimpleDemo.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
private void showPoland() { WKTReader r = new WKTReader(); try { Geometry g = r.read(s); g.setSRID(4326); Geometry g2 = g.buffer(1); Geometry g3 = g2.difference(g); JavaScriptObject f1 = parseWKT(g.toString()); JavaScriptObject f2 = parseWKT(g3.toString()); JsArray<JavaScriptObject> fs = JsArray.createArray().cast(); fs.push(f1); fs.push(f2); addFeatures(mMap, fs); } catch (ParseException e) { sLogger.log(Level.WARNING, "Unable to parse wkb", e); } }
Example 3
Source File: OverlaySerdesTest.java From requestor with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void testDeserializeCollection() throws Exception { DeserializationContext ctx = new DeserializationContext(JavaScriptObject.class) { @Override public <T> T getInstance(Class<T> type) { return (T) new ArrayList<Object>(); } }; String input = "[{\"name\":\"John Doe\",\"age\":31},{\"name\":\"Alice\",\"age\":27}]"; JsArray<JavaScriptObject> expected = (JsArray<JavaScriptObject>) JavaScriptObject.createArray(); expected.push(create("John Doe", 31)); expected.push(create("Alice", 27)); List<JavaScriptObject> output = serdes.deserialize(List.class, input, ctx); JsArray<JavaScriptObject> outputArray = (JsArray<JavaScriptObject>) JavaScriptObject.createArray(); outputArray.push(output.get(0)); outputArray.push(output.get(1)); assertEquals(JsonSerdes.stringify(expected), JsonSerdes.stringify(outputArray)); }
Example 4
Source File: DomHelper.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Gets a list of descendants of e that match the given class name. * * If the browser has the native method, that will be called. Otherwise, it * traverses descendents of the given element and returns the list of elements * with matching classname. * * @param e * @param className */ public static NodeList<Element> getElementsByClassName(Element e, String className) { if (QuirksConstants.SUPPORTS_GET_ELEMENTS_BY_CLASSNAME) { return getElementsByClassNameNative(e, className); } else { NodeList<Element> all = e.getElementsByTagName("*"); if (all == null) { return null; } JsArray<Element> ret = JavaScriptObject.createArray().cast(); for (int i = 0; i < all.getLength(); ++i) { Element item = all.getItem(i); if (className.equals(item.getClassName())) { ret.push(item); } } return ret.cast(); } }
Example 5
Source File: JsWebRTCProvider.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
@NotNull @Override public Promise<WebRTCPeerConnection> createPeerConnection(final WebRTCIceServer[] webRTCIceServers, WebRTCSettings settings) { return new Promise<>((PromiseFunc<WebRTCPeerConnection>) resolver -> { JsArray<JsIceServer> servers = JsArray.createArray().cast(); for (WebRTCIceServer s : webRTCIceServers) { if (s.getUsername() != null || s.getCredential() != null) { servers.push(JsIceServer.create(s.getUrl(), s.getUsername(), s.getCredential())); } else { servers.push(JsIceServer.create(s.getUrl())); } } resolver.result(new PeerConnection(JsPeerConnection.create(JsPeerConnectionConfig.create(servers)))); }); }
Example 6
Source File: JsFacade.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
@UsedByApp public JsArray<JsMentionFilterResult> findMentions(int gid, String query) { List<MentionFilterResult> res = messenger.findMentions(gid, query); JsArray<JsMentionFilterResult> mentions = JsArray.createArray().cast(); for (MentionFilterResult m : res) { mentions.push(JsMentionFilterResult.create(m)); } return mentions; }
Example 7
Source File: JsFacade.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
@UsedByApp public JsArray<JsBotCommand> findBotCommands(int uid, String query) { JsArray<JsBotCommand> commands = JsArray.createArray().cast(); for (BotCommand c : messenger.getUser(uid).getBotCommands().get()) { if (c.getSlashCommand().startsWith(query)) { commands.push(JsBotCommand.create(c.getSlashCommand(), c.getDescription())); } } return commands; }
Example 8
Source File: JsFacade.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
private JsArray<JsMessageSearchEntity> convertSearchRes(List<MessageSearchEntity> res) { JsArray<JsMessageSearchEntity> jsRes = JsArray.createArray().cast(); for (MessageSearchEntity e : res) { jsRes.push(JsMessageSearchEntity.create(e.getRid() + "", messenger.buildPeerInfo(Peer.user(e.getSenderId())), messenger.getFormatter().formatDate(e.getDate()), JsContent.createContent(e.getContent(), e.getSenderId()))); } return jsRes; }
Example 9
Source File: JsCall.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
public static JsCall create(JsMessenger messenger, CallVM model) { JsArray<JsPeerInfo> members = JsArray.createArray().cast(); for (CallMember member : model.getMembers().get()) { members.push(messenger.buildPeerInfo(Peer.user(member.getUid()))); } String state; switch (model.getState().get()) { case RINGING: state = "calling"; break; case CONNECTING: state = "connecting"; break; case IN_PROGRESS: state = "in_progress"; break; default: case ENDED: state = "ended"; break; } JsArray<JsMediaStreamTrack> tracks = JsArray.createArray().cast(); for (WebRTCMediaTrack track : model.getTheirVideoTracks().get()) { tracks.push(((MediaTrack) track).getTrack()); } ArrayList<WebRTCMediaTrack> ownTrack = model.getOwnVideoTracks().get(); return create(JsPeer.create(model.getPeer()), model.isOutgoing(), members, state, !model.getIsAudioEnabled().get(), ownTrack.size() == 0 ? null : ((MediaTrack) ownTrack.get(0)).getTrack(), tracks); }
Example 10
Source File: JsMessage.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
@Override public JsMessage convert(Message value) { JsMessenger messenger = JsMessenger.getInstance(); String rid = value.getRid() + ""; String sortKey = value.getSortDate() + ""; JsPeerInfo sender = messenger.buildPeerInfo(Peer.user(value.getSenderId())); boolean isOut = value.getSenderId() == messenger.myUid(); boolean isOnServer = value.isOnServer(); String date = messenger.getFormatter().formatTime(value.getDate()); JsDate fullDate = JsDate.create(value.getDate()); JsContent content = JsContent.createContent(value.getContent(), value.getSenderId()); JsArray<JsReaction> reactions = JsArray.createArray().cast(); for (Reaction r : value.getReactions()) { JsArrayInteger uids = (JsArrayInteger) JsArrayInteger.createArray(); boolean isOwnSet = false; for (Integer i : r.getUids()) { uids.push(i); if (i == messenger.myUid()) { isOwnSet = true; } } reactions.push(JsReaction.create(r.getCode(), uids, isOwnSet)); } double sortDate = value.getDate() / 1000.0; return create(rid, sortKey, sender, isOut, date, fullDate, Enums.convert(value.getMessageState()), isOnServer, content, reactions, sortDate); }
Example 11
Source File: SuggestionCallback.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
public void execute(final Collection<Suggestion<T>> suggestions) { JsArray<Suggestion<T>> jsArray = JsArrayString.createArray().cast(); if (suggestions != null) { for (Suggestion<T> s : suggestions) { jsArray.push(s); } } invokeCallback(jsCallback, jsArray); }
Example 12
Source File: Typeahead.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
protected void configure() { JsArray<JavaScriptObject> datasetJSOs = JsArray.createArray().cast(); for (Dataset<T> dataset : datasets) { JavaScriptObject jso = toJSO(dataset); datasetJSOs.push(jso); } configure(getElement(), highlight, hint, minLength, datasetJSOs); }
Example 13
Source File: AceCompletionCallbackImpl.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void invokeWithCompletions(AceCompletion[] proposals) { JsArray<JavaScriptObject> jsProposals = JavaScriptObject.createArray().cast(); for (AceCompletion proposal : proposals) { jsProposals.push(proposal.toJsObject()); } doInvokeWithCompletions(jsProposals); }
Example 14
Source File: JsGroup.java From actor-platform with GNU Affero General Public License v3.0 | 4 votes |
public static JsGroup fromGroupVM(GroupVM groupVM, JsMessenger messenger) { int online = groupVM.getPresence().get(); String presence = messenger.getFormatter().formatGroupMembers(groupVM.getMembersCount().get()); if (online > 0) { presence += ", " + messenger.getFormatter().formatGroupOnline(online); } String fileUrl = null; String bigFileUrl = null; Avatar avatar = groupVM.getAvatar().get(); if (avatar != null) { if (avatar.getSmallImage() != null) { fileUrl = messenger.getFileUrl(avatar.getSmallImage().getFileReference()); } if (avatar.getLargeImage() != null) { bigFileUrl = messenger.getFileUrl(avatar.getLargeImage().getFileReference()); } } ArrayList<JsGroupMember> convertedMembers = new ArrayList<JsGroupMember>(); HashSet<GroupMember> groupMembers = groupVM.getMembers().get(); GroupMember[] members = groupMembers.toArray(new GroupMember[groupMembers.size()]); for (GroupMember g : members) { JsPeerInfo peerInfo = messenger.buildPeerInfo(Peer.user(g.getUid())); // Log.d("JsGroup", "PeerInfo: " + peerInfo); convertedMembers.add(JsGroupMember.create(peerInfo, g.isAdministrator(), g.getInviterUid() == messenger.myUid())); } Collections.sort(convertedMembers, new Comparator<JsGroupMember>() { @Override public int compare(JsGroupMember o1, JsGroupMember o2) { return o1.getPeerInfo().getTitle().compareToIgnoreCase(o2.getPeerInfo().getTitle()); } }); JsArray<JsGroupMember> jsMembers = JsArray.createArray().cast(); for (JsGroupMember member : convertedMembers) { jsMembers.push(member); } return create(groupVM.getId(), groupVM.getName().get(), groupVM.getAbout().get(), fileUrl, bigFileUrl, Placeholders.getPlaceholder(groupVM.getId()), presence, jsMembers); }
Example 15
Source File: CalendarConfig.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
private void setParameter(final JsArray<JavaScriptObject> params, final IsJavaScriptObject isJS) { if (isJS != null) { params.push(isJS.toJavaScript()); } }