List of usage examples for com.google.gwt.gdata.client.finance PortfolioEntry getId
public final native Id getId() ;
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrievePortfolioDemo.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.//w ww. j a v a 2s . com * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry and * calls getPortfolio. The getPortfolio call will retrieve * the same portfolio that we already have, the goal * is to exemplify how to retrieve a portfolio directly. * * @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 portfolioEntryUri = targetPortfolio.getId().getValue(); getPortfolio(portfolioEntryUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrievePortfolioDemo.java
License:Apache License
/** * Displays a set of Finance portfolio entries in a tabular * fashion with the help of a GWT FlexTable widget. The data fields * Title and ID are displayed.//from ww w . j a v a2s. c o m * * @param entries The Finance portfolio entries to display. */ private void showData(PortfolioEntry[] entries) { mainPanel.clear(); String[] labels = new String[] { "Title", "ID" }; mainPanel.insertRow(0); for (int i = 0; i < labels.length; i++) { mainPanel.addCell(0); mainPanel.setWidget(0, i, new Label(labels[i])); mainPanel.getFlexCellFormatter().setStyleName(0, i, "hm-tableheader"); } for (int i = 0; i < entries.length; i++) { PortfolioEntry entry = entries[i]; int row = mainPanel.insertRow(i + 1); mainPanel.addCell(row); mainPanel.setWidget(row, 0, new Label(entry.getTitle().getText())); mainPanel.addCell(row); mainPanel.setWidget(row, 1, new Label(entry.getId().getValue())); } }
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 av a 2 s . c om*/ * 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); } } }); }