Example usage for com.google.gwt.gdata.client.finance PortfolioEntry setPortfolioData

List of usage examples for com.google.gwt.gdata.client.finance PortfolioEntry setPortfolioData

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.finance PortfolioEntry setPortfolioData.

Prototype

public final native void setPortfolioData(PortfolioData portfolioData) ;

Source Link

Document

Sets the data for the portfolio.

Usage

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./*from   w  w w.  ja va2 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);
        }
    });
}