List of usage examples for com.google.gwt.core.client JsArrayString length
public final native int length() ;
From source file:com.google.gerrit.client.diff.UnifiedChunkManager.java
License:Apache License
private int render(Region region, int cmLine, boolean useIntralineBg) { int startA = lineMapper.getLineA(); int startB = lineMapper.getLineB(); JsArrayString a = region.a(); JsArrayString b = region.b();/*from ww w. j a v a 2s . com*/ int aLen = a != null ? a.length() : 0; int bLen = b != null ? b.length() : 0; boolean insertOrDelete = a == null || b == null; colorLines(cm, insertOrDelete && !useIntralineBg ? UnifiedTable.style.diffDelete() : UnifiedTable.style.intralineDelete(), cmLine, aLen); colorLines(cm, insertOrDelete && !useIntralineBg ? UnifiedTable.style.diffInsert() : UnifiedTable.style.intralineInsert(), cmLine + aLen, bLen); markEdit(DisplaySide.A, cmLine, a, region.editA()); markEdit(DisplaySide.B, cmLine + aLen, b, region.editB()); addGutterTag(region, cmLine); // TODO: verify addGutterTag lineMapper.appendReplace(aLen, bLen); int endA = lineMapper.getLineA() - 1; int endB = lineMapper.getLineB() - 1; if (aLen > 0) { addDiffChunk(DisplaySide.A, endA, aLen, cmLine, bLen > 0); for (int j = 0; j < aLen; j++) { host.setLineNumber(DisplaySide.A, cmLine + j, startA + j + 1); host.setLineNumberEmpty(DisplaySide.B, cmLine + j); } } if (bLen > 0) { addDiffChunk(DisplaySide.B, endB, bLen, cmLine + aLen, aLen > 0); for (int j = 0; j < bLen; j++) { host.setLineNumberEmpty(DisplaySide.A, cmLine + aLen + j); host.setLineNumber(DisplaySide.B, cmLine + aLen + j, startB + j + 1); } } return aLen + bLen; }
From source file:com.google.gerrit.client.info.ChangeInfo.java
License:Apache License
/** * @return the index of the missing label or -1 if no label is missing, or if more than one label * is missing.//from w ww . j a v a2s.c om */ public final int getMissingLabelIndex() { int i = -1; int ret = -1; List<LabelInfo> labels = Natives.asList(allLabels().values()); for (LabelInfo label : labels) { i++; if (!permittedLabels().containsKey(label.name())) { continue; } JsArrayString values = permittedValues(label.name()); if (values.length() == 0) { continue; } switch (label.status()) { case NEED: // Label is required for submit. if (ret != -1) { // more than one label is missing, so it's unclear which to quick // approve, return -1 return -1; } ret = i; continue; case OK: // Label already applied. case MAY: // Label is not required. continue; case REJECT: // Submit cannot happen, do not quick approve. case IMPOSSIBLE: return -1; } } return ret; }
From source file:com.google.gerrit.client.info.GerritInfo.java
License:Apache License
public final List<UiType> webUis() { JsArrayString webUis = _webUis(); List<UiType> result = new ArrayList<>(webUis.length()); for (int i = 0; i < webUis.length(); i++) { UiType t = UiType.parse(webUis.get(i)); if (t != null) { result.add(t);// w w w . jav a 2 s.co m } } return result; }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerCreateBlogPostCommentDemo.java
License:Apache License
/** * Retrieve the Blogger posts feed using the Blogger service and * the posts feed uri for a given blog.//from ww w . ja v a 2 s.com * On success, identify the first post entry that is available * for commenting, this will be the post entry that we'll * reply to. * If no posts are available for commenting, display a message. * Otherwise extract the blog and post ID and call insertComment * to add a comment. * If the regular expression parsing of the blog and post IDs * fails, display a message. * * @param postsFeedUri The posts feed uri for a given blog */ private void getPosts(String postsFeedUri) { showStatus("Loading posts feed...", false); service.getBlogPostFeed(postsFeedUri, new BlogPostFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the Blogger Posts " + "feed: " + caught.getMessage(), true); } public void onSuccess(BlogPostFeed result) { PostEntry targetPost = null; // get the first public post for (PostEntry post : result.getEntries()) { if (post.getRepliesLink() != null) { targetPost = post; break; } } if (targetPost == null) { showStatus("The target blog contains no public posts.", false); } else { String postEntryId = targetPost.getId().getValue(); JsArrayString match = regExpMatch("blog-(\\d+)\\.post-(\\d+)", postEntryId); if (match.length() > 1) { insertComment(match.get(1), match.get(2)); } else { showStatus("Error parsing the blog post id.", true); } } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrievePositionsDemo.java
License:Apache License
/** * Retrieve the portfolios feed using the Finance service and * the portfolios feed uri. In GData all get, insert, update * and delete methods always receive a callback defining * success and failure handlers.//from w w w . j a va 2 s .com * Here, the failure handler displays an error message while the * success handler obtains the first portfolio entry and its * ID and calls getPositions to retrieve the corresponding * positions feed. * * @param portfoliosFeedUri The uri of the portfolios feed */ private void getPortfolios(String portfoliosFeedUri) { showStatus("Loading portfolios feed...", false); service.getPortfolioFeed(portfoliosFeedUri, new PortfolioFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the portfolios feed: " + caught.getMessage(), true); } public void onSuccess(PortfolioFeed result) { PortfolioEntry[] entries = result.getEntries(); if (entries.length == 0) { showStatus("You have no portfolios.", false); } else { PortfolioEntry targetPortfolio = entries[0]; String portfolioId = targetPortfolio.getId().getValue(); JsArrayString match = regExpMatch("\\/(\\d+)$", portfolioId); if (match.length() > 1) { portfolioId = match.get(1); } else { showStatus("Error parsing the portfolio id.", true); } getPositions(portfolioId); } } }); }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
public final HashSet<String> getContributorIds() { JsArrayString sArr = getContributorIds_(); HashSet<String> arr = new HashSet<String>(); for (int i = 0; i < sArr.length(); ++i) { arr.add(sArr.get(i));/* w w w . jav a2 s .c o m*/ } return arr; }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
public final HashSet<String> getViewerIds() { JsArrayString sArr = getViewerIds_(); HashSet<String> arr = new HashSet<String>(); for (int i = 0; i < sArr.length(); ++i) { arr.add(sArr.get(i));/*from w w w . j ava2 s . c om*/ } return arr; }
From source file:com.google.mobile.trippy.web.client.db.JsoTripItem.java
License:Apache License
public final ArrayList<String> getPhoneNumbers() { ArrayList<String> parr = new ArrayList<String>(); JsArrayString jarr = getPhoneNumbers_(); for (int i = 0; i < jarr.length(); ++i) { parr.add(jarr.get(i));//from w w w.jav a2 s. c o m } return parr; }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
/** * Get trips from main index.// w w w.ja v a 2 s. c o m */ public ArrayList<Trip> getTrips() { JsArrayString tripKeys = getIndexKeys(KEY_LOCAL_STORE_TRIPS); ArrayList<Trip> trips = new ArrayList<Trip>(); for (int i = 0; i < tripKeys.length(); ++i) { trips.add(getTripForKey(tripKeys.get(i))); } return trips; }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void addTrip(final Trip trip) { JsoTrip jsoTrip = (JsoTrip) JavaScriptObject.createObject(); jsoTrip.setTrip(trip);// w ww.j av a 2s. c o m final String tripKey = KEY_LOCAL_STORE_TRIP_PREFIX + trip.getKey(); LocalDbService.makePersistent(tripKey, new JSONObject(jsoTrip).toString()); final JsArrayString tripKeys = getIndexKeys(KEY_LOCAL_STORE_TRIPS); for (int i = 0; i < tripKeys.length(); ++i) { if (tripKeys.get(i).equals(tripKey)) { return; } } tripKeys.push(tripKey); setIndexKeys(KEY_LOCAL_STORE_TRIPS, tripKeys); eventBus.fireEvent(new TripAddedEvent(trip)); }