Search in sources :

Example 6 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class AbstractQuoteProviderPage method setupInitialData.

private void setupInitialData() {
    QuoteFeed feed = getQuoteFeedProvider(getFeed());
    if (feed != null)
        comboProvider.setSelection(new StructuredSelection(feed));
    else
        comboProvider.getCombo().select(0);
    createDetailDataWidgets(feed);
    if (// $NON-NLS-1$
    model.getTickerSymbol() != null && feed != null && feed.getId() != null && feed.getId().startsWith("YAHOO")) {
        Exchange exchange = new Exchange(model.getTickerSymbol(), model.getTickerSymbol());
        ArrayList<Exchange> input = new ArrayList<>();
        input.add(exchange);
        comboExchange.setInput(input);
        comboExchange.setSelection(new StructuredSelection(exchange));
    } else if (textFeedURL != null) {
        textFeedURL.setText(getFeedURL());
    }
}
Also used : Exchange(name.abuchen.portfolio.model.Exchange) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Example 7 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class AbstractQuoteProviderPage method onTickerSymbolChanged.

private void onTickerSymbolChanged() {
    boolean hasTicker = model.getTickerSymbol() != null && !model.getTickerSymbol().isEmpty();
    if (!hasTicker) {
        clearSampleQuotes();
        setStatus(MessageFormat.format(Messages.MsgDialogInputRequired, Messages.ColumnTicker));
    } else {
        QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) comboProvider.getSelection()).getFirstElement();
        showSampleQuotes(feed, null);
        setStatus(null);
    }
}
Also used : AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Example 8 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class AbstractQuoteProviderPage method onFeedURLChanged.

private void onFeedURLChanged() {
    setFeedURL(textFeedURL.getText());
    boolean hasURL = getFeedURL() != null && getFeedURL().length() > 0;
    if (!hasURL) {
        clearSampleQuotes();
        setStatus(MessageFormat.format(Messages.EditWizardQuoteFeedMsgErrorMissingURL, getTitle()));
    } else {
        QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) comboProvider.getSelection()).getFirstElement();
        showSampleQuotes(feed, null);
        setStatus(null);
    }
}
Also used : AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Example 9 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class AbstractQuoteProviderPage method afterPage.

@Override
public void afterPage() {
    QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) comboProvider.getSelection()).getFirstElement();
    setFeed(feed.getId());
    if (comboExchange != null && feed.getId() != null && feed.getId().startsWith(YAHOO)) {
        Exchange exchange = (Exchange) ((IStructuredSelection) comboExchange.getSelection()).getFirstElement();
        if (exchange != null) {
            model.setTickerSymbol(exchange.getId());
            tickerSymbol = exchange.getId();
            setFeedURL(null);
        }
    } else if (textFeedURL != null) {
        setFeedURL(textFeedURL.getText());
    }
}
Also used : Exchange(name.abuchen.portfolio.model.Exchange) AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed)

Example 10 with QuoteFeed

use of name.abuchen.portfolio.online.QuoteFeed in project portfolio by buchen.

the class AbstractQuoteProviderPage method createDetailDataWidgets.

private void createDetailDataWidgets(QuoteFeed feed) {
    boolean dropDown = feed != null && feed.getId() != null && feed.getId().startsWith(YAHOO);
    boolean feedURL = feed != null && feed.getId() != null && feed.getId().equals(HTMLTableQuoteFeed.ID);
    boolean needsTicker = feed != null && feed.getId() != null && feed.getId().equals(AlphavantageQuoteFeed.ID);
    if (textFeedURL != null) {
        textFeedURL.dispose();
        textFeedURL = null;
    }
    if (comboExchange != null) {
        comboExchange.getControl().dispose();
        comboExchange = null;
    }
    if (textTicker != null) {
        textTicker.dispose();
        textTicker = null;
        // $NON-NLS-1$
        model.removePropertyChangeListener("tickerSymbol", tickerSymbolPropertyChangeListener);
    }
    if (dropDown) {
        labelDetailData.setText(Messages.LabelExchange);
        comboExchange = new ComboViewer(grpQuoteFeed, SWT.READ_ONLY);
        comboExchange.setContentProvider(ArrayContentProvider.getInstance());
        comboExchange.setLabelProvider(new LabelProvider() {

            @Override
            public String getText(Object element) {
                return ((Exchange) element).getName();
            }
        });
        GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(comboExchange.getControl());
        comboExchange.addSelectionChangedListener(this::onExchangeChanged);
    } else if (feedURL) {
        labelDetailData.setText(Messages.EditWizardQuoteFeedLabelFeedURL);
        textFeedURL = new Text(grpQuoteFeed, SWT.BORDER);
        GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(textFeedURL);
        textFeedURL.addModifyListener(e -> onFeedURLChanged());
    } else if (needsTicker) {
        labelDetailData.setText(Messages.ColumnTicker);
        textTicker = new Text(grpQuoteFeed, SWT.BORDER);
        GridDataFactory.fillDefaults().hint(100, SWT.DEFAULT).applyTo(textTicker);
        ISWTObservableValue observeText = WidgetProperties.text(SWT.Modify).observe(textTicker);
        // $NON-NLS-1$
        bindings.getBindingContext().bindValue(observeText, BeanProperties.value("tickerSymbol").observe(model));
        // $NON-NLS-1$
        model.addPropertyChangeListener("tickerSymbol", tickerSymbolPropertyChangeListener);
    } else {
        // $NON-NLS-1$
        labelDetailData.setText("");
    }
    grpQuoteFeed.layout(true);
    grpQuoteFeed.getParent().layout();
}
Also used : SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) HashMap(java.util.HashMap) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) Exchange(name.abuchen.portfolio.model.Exchange) ComboViewer(org.eclipse.jface.viewers.ComboViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) WidgetProperties(org.eclipse.jface.databinding.swt.WidgetProperties) IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) Map(java.util.Map) FillLayout(org.eclipse.swt.layout.FillLayout) BindingHelper(name.abuchen.portfolio.ui.util.BindingHelper) Text(org.eclipse.swt.widgets.Text) Job(org.eclipse.core.runtime.jobs.Job) FormLayout(org.eclipse.swt.layout.FormLayout) AlphavantageQuoteFeed(name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) FormData(org.eclipse.swt.layout.FormData) Status(org.eclipse.core.runtime.Status) Security(name.abuchen.portfolio.model.Security) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Group(org.eclipse.swt.widgets.Group) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) HTMLTableQuoteFeed(name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) PortfolioPlugin(name.abuchen.portfolio.ui.PortfolioPlugin) Objects(java.util.Objects) List(java.util.List) PropertyChangeListener(java.beans.PropertyChangeListener) BeanProperties(org.eclipse.core.databinding.beans.BeanProperties) SWT(org.eclipse.swt.SWT) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) Label(org.eclipse.swt.widgets.Label) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) Text(org.eclipse.swt.widgets.Text) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

QuoteFeed (name.abuchen.portfolio.online.QuoteFeed)13 HTMLTableQuoteFeed (name.abuchen.portfolio.online.impl.HTMLTableQuoteFeed)10 AlphavantageQuoteFeed (name.abuchen.portfolio.online.impl.AlphavantageQuoteFeed)8 ArrayList (java.util.ArrayList)6 Exchange (name.abuchen.portfolio.model.Exchange)5 Security (name.abuchen.portfolio.model.Security)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 MessageFormat (java.text.MessageFormat)2 List (java.util.List)2 Messages (name.abuchen.portfolio.ui.Messages)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 URISyntaxException (java.net.URISyntaxException)1 LocalDate (java.time.LocalDate)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 BiFunction (java.util.function.BiFunction)1