Example usage for com.google.gwt.gdata.client.finance PortfolioEntryCallback PortfolioEntryCallback

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

Introduction

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

Prototype

PortfolioEntryCallback

Source Link

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 .  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.FinanceDeletePortfolioDemo.java

License:Apache License

/**
 * Delete a portfolio entry using the Finance service and
 * the portfolio entry uri./*from  w w  w . jav a  2  s .co  m*/
 * On success and failure, display a status message.
 * 
 * @param portfolioEntryUri The uri of the portfolio entry to delete
 */
private void deletePortfolio(String portfolioEntryUri) {
    showStatus("Deleting portfolio...", false);
    service.deleteEntry(portfolioEntryUri, new PortfolioEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the portfolios feed: " + caught.getMessage(), true);
        }

        public void onSuccess(PortfolioEntry result) {
            showStatus("Deleted a portfolio.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.FinanceRetrievePortfolioDemo.java

License:Apache License

/**
 * Retrieves a portfolio entry by uri. On success, call
 * showData to display the portfolio entry details.
 * //from   ww w. j  av a 2 s  .c om
 * @param portfolioEntryUri The uri of the portfolio
 * entry to retrieve
 */
private void getPortfolio(String portfolioEntryUri) {
    showStatus("Loading portfolio entry...", false);
    service.getPortfolioEntry(portfolioEntryUri, new PortfolioEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving a portfolio entry: " + caught.getMessage(), true);
        }

        public void onSuccess(PortfolioEntry result) {
            showData(new PortfolioEntry[] { result });
        }
    });
}

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 w  w.  j av  a 2  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);
        }
    });
}