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

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

Introduction

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

Prototype

public final native void setTitle(Text title) ;

Source Link

Document

Sets the title.

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   ww w.ja v  a  2  s  .  co  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.FinanceUpdatePortfolioDemo.java

License:Apache License

/**
 * Update a portfolio by making use of the updateEntry
 * method of the Entry class.//from   w ww.j a  v a2s . c  om
 * 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);
        }
    });
}