List of usage examples for com.google.gwt.gdata.client.finance PortfolioEntry getTitle
public final native Text getTitle() ;
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceCreatePortfolioDemo.java
License:Apache License
/** * Create a portfolio by inserting a portfolio entry into * a portfolio feed.// w w w .j a v a 2 s. c o m * Set the portfolio's title to an arbitrary string. Here * we prefix the title with 'GWT-Finance-Client' so that * we can identify which portfolios were created by this demo. * The new portfolio is created with currency code set to USD. * On success and failure, display a status message. * * @param portfolioFeedUri The uri of the portfolio feed into which * to insert the portfolio entry */ private void createPortfolio(String portfolioFeedUri) { showStatus("Creating portfolio...", false); PortfolioEntry entry = PortfolioEntry.newInstance(); entry.setTitle(Text.newInstance()); entry.getTitle().setText("GWT-Finance-Client - inserted portfolio"); PortfolioData data = PortfolioData.newInstance(); data.setCurrencyCode("USD"); entry.setPortfolioData(data); service.insertEntry(portfolioFeedUri, entry, new PortfolioEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while creating a portfolio: " + caught.getMessage(), true); } public void onSuccess(PortfolioEntry result) { showStatus("Created a portfolio.", false); } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceCreateTransactionDemo.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 ww w.ja va2 s. co m*/ * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry with a title * starting with "GWT-Finance-Client" and calls createTransaction * to insert a transaction. * If no portfolio is found a message is displayed. * * @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(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { String portfolioEditUri = targetPortfolio.getEditLink().getHref(); createTransaction(portfolioEditUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceDeletePortfolioDemo.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 ww. java 2s . c om * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry with a title * starting with "GWT-Finance-Client" and calls deletePortfolio * to delete the portfolio. Alternatively we could also have used * targetPortfolio.deleteEntry but the effect is the same. * If no portfolio is found a message is displayed. * * @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(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { String portfolioEntryUri = targetPortfolio.getSelfLink().getHref(); deletePortfolio(portfolioEntryUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceDeleteTransactionDemo.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 v a 2s.c om * Here, the failure handler displays an error message while the * success handler obtains the first Portfolio entry with a title * starting with "GWT-Finance-Client" and retrieves the first * transaction in the portfolio with the symbol "NASDAQ:GOOG", * this is the transaction that will be deleted. * If no transaction exists with this symbol, the request will fail. * If no portfolio is found, a message is displayed. * * @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(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { final String ticker = "NASDAQ:GOOG"; int transactionId = 1; String transactionEntryUri = targetPortfolio.getEditLink().getHref() + "/positions/" + ticker + "/transactions/" + transactionId; getTransaction(transactionEntryUri); } } }); }
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 www .j a va2s .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.FinanceRetrieveTransactionsDemo.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 ava2 s . co m*/ * Here, the failure handler displays an error message while the * success handler obtains the first portfolio entry with a title * starting with "GWT-Finance-Client" and retrieves all transactions * with the ticker symbol "NASDAQ:GOOG". * If no transactions exist with this symbol, the request will fail. * If no portfolio is found, a message is displayed. * * @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(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { String ticker = "NASDAQ:GOOG"; String transactionFeedUri = targetPortfolio.getEditLink().getHref() + "/positions/" + ticker + "/transactions"; getTransactions(transactionFeedUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceUpdatePortfolioDemo.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 v a2 s. c o m * Here, the failure handler displays an error message while the * success handler obtains the first portfolio entry with a title * starting with "GWT-Finance-Client" and calls updatePortfolio to * update the portfolio. * If no portfolio is found, a message is displayed. * * @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(); PortfolioEntry targetPortfolio = null; for (PortfolioEntry entry : entries) { if (entry.getTitle().getText().startsWith("GWT-Finance-Client")) { targetPortfolio = entry; break; } } if (targetPortfolio == null) { showStatus("No portfolio found that contains 'GWT-Finance-Client' " + "in the title.", false); } else { updatePortfolio(targetPortfolio); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceUpdatePortfolioDemo.java
License:Apache License
/** * Update a portfolio by making use of the updateEntry * method of the Entry class./* w w w.ja v a2 s .c o m*/ * Set the portfolio title to an arbitrary string. Here * we prefix the title with 'GWT-Finance-Client' so that * we can identify which portfolios were updated by this demo. * On success and failure, display a status message. * * @param targetPortfolio The portfolio entry which to update */ private void updatePortfolio(PortfolioEntry targetPortfolio) { showStatus("Updating portfolio...", false); targetPortfolio.setTitle(Text.newInstance()); targetPortfolio.getTitle().setText("GWT-Finance-Client - updated portfolio"); targetPortfolio.updateEntry(new PortfolioEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while updating a portfolio: " + caught.getMessage(), true); } public void onSuccess(PortfolioEntry result) { showStatus("Updated a portfolio.", false); } }); }