Search in sources :

Example 6 with CurrencyUnit

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);
}
Also used : Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) ToolBar(org.eclipse.swt.widgets.ToolBar) Images(name.abuchen.portfolio.ui.Images) Inject(javax.inject.Inject) Composite(org.eclipse.swt.widgets.Composite) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) Messages(name.abuchen.portfolio.ui.Messages) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) Separator(org.eclipse.jface.action.Separator) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) DateSelectionDialog(name.abuchen.portfolio.ui.dialogs.DateSelectionDialog) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) List(java.util.List) PropertyChangeListener(java.beans.PropertyChangeListener) IMenuManager(org.eclipse.jface.action.IMenuManager) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) Collections(java.util.Collections) ClientSnapshot(name.abuchen.portfolio.snapshot.ClientSnapshot) Control(org.eclipse.swt.widgets.Control) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) IMenuManager(org.eclipse.jface.action.IMenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter)

Example 7 with CurrencyUnit

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) Composite(org.eclipse.swt.widgets.Composite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 8 with CurrencyUnit

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();
}
Also used : CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit)

Aggregations

CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)8 Label (org.eclipse.swt.widgets.Label)3 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 Composite (org.eclipse.swt.widgets.Composite)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 ParseException (java.text.ParseException)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 StringJoiner (java.util.StringJoiner)1 Inject (javax.inject.Inject)1 Client (name.abuchen.portfolio.model.Client)1 Type (name.abuchen.portfolio.model.PortfolioTransaction.Type)1 Security (name.abuchen.portfolio.model.Security)1 Unit (name.abuchen.portfolio.model.Transaction.Unit)1 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)1 CurrencyConverterImpl (name.abuchen.portfolio.money.CurrencyConverterImpl)1 ExchangeRateProviderFactory (name.abuchen.portfolio.money.ExchangeRateProviderFactory)1