use of name.abuchen.portfolio.model.Exchange in project portfolio by buchen.
the class AbstractQuoteProviderPage method onExchangeChanged.
private void onExchangeChanged(SelectionChangedEvent event) {
Exchange exchange = (Exchange) ((IStructuredSelection) event.getSelection()).getFirstElement();
setStatus(null);
if (exchange == null) {
clearSampleQuotes();
} else {
QuoteFeed feed = (QuoteFeed) ((IStructuredSelection) comboProvider.getSelection()).getFirstElement();
showSampleQuotes(feed, exchange);
}
}
use of name.abuchen.portfolio.model.Exchange in project portfolio by buchen.
the class YahooFinanceQuoteFeedTest method testThatAtLeastTheGivenExchangeIsReturned.
@Test
public void testThatAtLeastTheGivenExchangeIsReturned() throws IOException {
YahooFinanceQuoteFeed feed = new YahooFinanceQuoteFeed() {
@Override
protected void searchSymbols(List<Exchange> answer, String query) throws IOException {
throw new IOException();
}
};
Security s = new Security();
s.setTickerSymbol("BAS.DE");
ArrayList<Exception> errors = new ArrayList<Exception>();
List<Exchange> exchanges = feed.getExchanges(s, errors);
assertThat(exchanges.size(), is(1));
assertThat(exchanges.get(0).getId(), is("BAS.DE"));
assertThat(errors.size(), is(1));
}
use of name.abuchen.portfolio.model.Exchange 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());
}
}
use of name.abuchen.portfolio.model.Exchange 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());
}
}
use of name.abuchen.portfolio.model.Exchange 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();
}
Aggregations