use of name.abuchen.portfolio.money.CurrencyUnit in project portfolio by buchen.
the class StatementOfAssetsView method addButtons.
@Override
protected void addButtons(final ToolBar toolBar) {
AbstractDropDown dropdown = new AbstractDropDown(toolBar, getClient().getBaseCurrency()) {
@Override
public void menuAboutToShow(IMenuManager manager) {
List<CurrencyUnit> available = CurrencyUnit.getAvailableCurrencyUnits();
Collections.sort(available);
for (final CurrencyUnit unit : available) {
Action action = new SimpleAction(unit.getLabel(), a -> {
setLabel(unit.getCurrencyCode());
getClient().setBaseCurrency(unit.getCurrencyCode());
});
action.setChecked(getClient().getBaseCurrency().equals(unit.getCurrencyCode()));
manager.add(action);
}
}
};
currencyChangeListener = e -> dropdown.setLabel(e.getNewValue().toString());
// $NON-NLS-1$
getClient().addPropertyChangeListener("baseCurrency", currencyChangeListener);
addCalendarButton(toolBar);
this.clientFilter = new ClientFilterDropDown(toolBar, getClient(), getPreferenceStore(), StatementOfAssetsView.class.getSimpleName(), filter -> notifyModelUpdated());
Action export = new SimpleAction(null, action -> new TableViewerCSVExporter(assetViewer.getTableViewer()).export(// $NON-NLS-1$
Messages.LabelStatementOfAssets + ".csv"));
export.setImageDescriptor(Images.EXPORT.descriptor());
export.setToolTipText(Messages.MenuExportData);
new ActionContributionItem(export).fill(toolBar, -1);
Action save = new SimpleAction(null, a -> assetViewer.showSaveMenu(getActiveShell()));
save.setImageDescriptor(Images.SAVE.descriptor());
save.setToolTipText(Messages.MenuSaveColumns);
new ActionContributionItem(save).fill(toolBar, -1);
Action config = new SimpleAction(null, a -> assetViewer.showConfigMenu(toolBar.getShell()));
config.setImageDescriptor(Images.CONFIG.descriptor());
config.setToolTipText(Messages.MenuShowHideColumns);
new ActionContributionItem(config).fill(toolBar, -1);
}
use of name.abuchen.portfolio.money.CurrencyUnit in project portfolio by buchen.
the class BaseCurrencySelectionPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
setControl(container);
container.setLayout(new FormLayout());
Label label = new Label(container, SWT.NONE);
label.setText(Messages.ColumnCurrency);
List<CurrencyUnit> currencies = CurrencyUnit.getAvailableCurrencyUnits();
Collections.sort(currencies);
combo = new ComboViewer(container);
combo.setContentProvider(ArrayContentProvider.getInstance());
combo.setInput(currencies);
combo.setSelection(new StructuredSelection(CurrencyUnit.getInstance(CurrencyUnit.EUR)));
Label description = new Label(container, SWT.WRAP);
description.setText(this.explanationIndividualCurrency);
FormDataFactory.startingWith(combo.getControl(), label).thenBelow(description).width(500).left(label);
container.pack();
setPageComplete(true);
}
use of name.abuchen.portfolio.money.CurrencyUnit in project portfolio by buchen.
the class BaseCSVExtractor method getCurrencyCode.
protected String getCurrencyCode(String name, String[] rawValues, Map<String, Column> field2column) {
String value = getText(name, rawValues, field2column);
if (value == null)
return client.getBaseCurrency();
CurrencyUnit unit = CurrencyUnit.getInstance(value.trim());
return unit == null ? client.getBaseCurrency() : unit.getCurrencyCode();
}
Aggregations