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());
}
}
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);
}
}
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);
}
}
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());
}
}
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();
}
Aggregations