Search in sources :

Example 6 with Exchange

use of name.abuchen.portfolio.model.Exchange in project portfolio by buchen.

the class AbstractQuoteProviderPage method onFeedProviderChanged.

private void onFeedProviderChanged(SelectionChangedEvent event) {
    String previousExchangeId = null;
    if (comboExchange != null) {
        Exchange exchange = (Exchange) ((IStructuredSelection) comboExchange.getSelection()).getFirstElement();
        if (exchange != null)
            previousExchangeId = exchange.getId();
    }
    if (previousExchangeId == null && model.getTickerSymbol() != null) {
        previousExchangeId = model.getTickerSymbol();
    }
    QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) event.getSelection()).getFirstElement();
    createDetailDataWidgets(feed);
    if (comboExchange != null) {
        List<Exchange> exchanges = cacheExchanges.get(feed);
        comboExchange.setInput(exchanges);
        // select exchange if other provider supports same exchange id
        // (yahoo close vs. yahoo adjusted close)
        boolean exchangeSelected = false;
        if (exchanges != null && previousExchangeId != null) {
            for (Exchange e : exchanges) {
                if (e.getId().equals(previousExchangeId)) {
                    comboExchange.setSelection(new StructuredSelection(e));
                    exchangeSelected = true;
                    break;
                }
            }
        }
        if (!exchangeSelected)
            comboExchange.setSelection(null);
        setStatus(exchangeSelected ? null : MessageFormat.format(Messages.MsgErrorExchangeMissing, getTitle()));
    } else if (textFeedURL != null) {
        boolean hasURL = getFeedURL() != null && getFeedURL().length() > 0;
        if (hasURL)
            textFeedURL.setText(getFeedURL());
        setStatus(hasURL ? null : MessageFormat.format(Messages.EditWizardQuoteFeedMsgErrorMissingURL, getTitle()));
    } else {
        // get sample quotes?
        if (feed != null) {
            showSampleQuotes(feed, null);
        } else {
            clearSampleQuotes();
        }
        setStatus(null);
    }
}
Also used : Exchange(name.abuchen.portfolio.model.Exchange) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Aggregations

Exchange (name.abuchen.portfolio.model.Exchange)6 QuoteFeed (name.abuchen.portfolio.online.QuoteFeed)5 AlphavantageQuoteFeed (name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed)5 HTMLTableQuoteFeed (name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed)5 ArrayList (java.util.ArrayList)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 List (java.util.List)2 Security (name.abuchen.portfolio.model.Security)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 IOException (java.io.IOException)1 MessageFormat (java.text.MessageFormat)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Messages (name.abuchen.portfolio.ui.Messages)1 PortfolioPlugin (name.abuchen.portfolio.ui.PortfolioPlugin)1 BindingHelper (name.abuchen.portfolio.ui.util.BindingHelper)1 BeanProperties (org.eclipse.core.databinding.beans.BeanProperties)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1