Search in sources :

Example 11 with CurrencyConverterImpl

use of name.abuchen.portfolio.money.CurrencyConverterImpl in project portfolio by buchen.

the class SecurityListView method createBottomTable.

// //////////////////////////////////////////////////////////////
// bottom table: folder
// //////////////////////////////////////////////////////////////
@Override
protected void createBottomTable(Composite parent) {
    Composite sash = new Composite(parent, SWT.NONE);
    sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
    // folder
    CTabFolder folder = new CTabFolder(sash, SWT.BORDER);
    // latest
    latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
    latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
    // tab 1: chart
    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabChart);
    Composite chartComposite = new Composite(folder, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(chartComposite);
    item.setControl(chartComposite);
    chart = new SecuritiesChart(chartComposite, getClient(), new CurrencyConverterImpl(factory, getClient().getBaseCurrency()));
    // tab 2: historical quotes
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabHistoricalQuotes);
    item.setControl(createPricesTable(folder));
    // tab 3: transactions
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabTransactions);
    item.setControl(createTransactionTable(folder));
    // tab 4: event
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabEvents);
    item.setControl(createEventsTable(folder));
    folder.setSelection(0);
}
Also used : SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) CTabItem(org.eclipse.swt.custom.CTabItem) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl)

Example 12 with CurrencyConverterImpl

use of name.abuchen.portfolio.money.CurrencyConverterImpl in project portfolio by buchen.

the class PerformanceView method reportingPeriodUpdated.

@Override
public void reportingPeriodUpdated() {
    ReportingPeriod period = getReportingPeriod();
    CurrencyConverter converter = new CurrencyConverterImpl(factory, getClient().getBaseCurrency());
    Client filteredClient = clientFilter.getSelectedFilter().filter(getClient());
    ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(filteredClient, converter, period);
    try {
        calculation.getTree().setRedraw(false);
        calculation.setInput(snapshot);
        calculation.expandAll();
        calculation.getTree().getParent().layout();
    } finally {
        calculation.getTree().setRedraw(true);
    }
    snapshotStart.setInput(snapshot.getStartClientSnapshot(), clientFilter.getSelectedFilter());
    snapshotEnd.setInput(snapshot.getEndClientSnapshot(), clientFilter.getSelectedFilter());
    earnings.setInput(snapshot.getEarnings());
    earningsByAccount.setInput(new GroupEarningsByAccount(snapshot).getItems());
    taxes.setInput(snapshot.getTaxes());
    fees.setInput(snapshot.getFees());
}
Also used : ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) GroupEarningsByAccount(name.abuchen.portfolio.snapshot.GroupEarningsByAccount) Client(name.abuchen.portfolio.model.Client) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) ClientPerformanceSnapshot(name.abuchen.portfolio.snapshot.ClientPerformanceSnapshot)

Example 13 with CurrencyConverterImpl

use of name.abuchen.portfolio.money.CurrencyConverterImpl in project portfolio by buchen.

the class PortfolioListView method createTopTable.

// //////////////////////////////////////////////////////////////
// top table: accounts
// //////////////////////////////////////////////////////////////
protected void createTopTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    portfolios = new TableViewer(container, SWT.FULL_SELECTION);
    ColumnEditingSupport.prepare(portfolios);
    portfolioColumns = new // $NON-NLS-1$
    ShowHideColumnHelper(// $NON-NLS-1$
    PortfolioListView.class.getSimpleName() + "@top2", getPreferenceStore(), portfolios, layout);
    // $NON-NLS-1$
    Column column = new NameColumn("0", Messages.ColumnPortfolio, SWT.None, 100);
    column.setLabelProvider(new NameColumnLabelProvider() {

        @Override
        public Color getForeground(Object e) {
            boolean isRetired = ((Portfolio) e).isRetired();
            return isRetired ? Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY) : null;
        }
    });
    column.getEditingSupport().addListener(this);
    portfolioColumns.addColumn(column);
    column = new Column(Messages.ColumnReferenceAccount, SWT.None, 160);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            Portfolio p = (Portfolio) e;
            return p.getReferenceAccount() != null ? p.getReferenceAccount().getName() : null;
        }
    });
    // $NON-NLS-1$
    ColumnViewerSorter.create(Portfolio.class, "referenceAccount").attachTo(column);
    // $NON-NLS-1$
    new ListEditingSupport(Portfolio.class, "referenceAccount", getClient().getAccounts()).addListener(this).attachTo(column);
    portfolioColumns.addColumn(column);
    column = new NoteColumn();
    column.getEditingSupport().addListener(this);
    portfolioColumns.addColumn(column);
    portfolioColumns.createColumns();
    portfolios.getTable().setHeaderVisible(true);
    portfolios.getTable().setLinesVisible(true);
    portfolios.setContentProvider(ArrayContentProvider.getInstance());
    setInput();
    portfolios.addSelectionChangedListener(event -> {
        Portfolio portfolio = (Portfolio) ((IStructuredSelection) event.getSelection()).getFirstElement();
        if (portfolio != null) {
            transactions.setInput(portfolio, portfolio.getTransactions());
            transactions.refresh();
            CurrencyConverter converter = new CurrencyConverterImpl(factory, portfolio.getReferenceAccount().getCurrencyCode());
            statementOfAssets.setInput(PortfolioSnapshot.create(portfolio, converter, LocalDate.now()));
        } else {
            transactions.setInput(null, null);
            transactions.refresh();
            statementOfAssets.setInput((PortfolioSnapshot) null);
        }
    });
    hookContextMenu(portfolios.getTable(), this::fillPortfolioContextMenu);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Color(org.eclipse.swt.graphics.Color) Portfolio(name.abuchen.portfolio.model.Portfolio) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) ListEditingSupport(name.abuchen.portfolio.ui.util.viewers.ListEditingSupport) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 14 with CurrencyConverterImpl

use of name.abuchen.portfolio.money.CurrencyConverterImpl in project portfolio by buchen.

the class DividendsView method setupModel.

@PostConstruct
public void setupModel() {
    CurrencyConverterImpl converter = new CurrencyConverterImpl(factory, client.getBaseCurrency());
    model = new DividendsViewModel(preferences, converter, client);
    int year = preferences.getInt(KEY_YEAR);
    LocalDate now = LocalDate.now();
    if (year < 1900 || year > now.getYear())
        year = now.getYear() - 2;
    model.updateWith(year);
    boolean useGrossValue = preferences.getBoolean(KEY_USE_GROSS_VALUE);
    model.setUseGrossValue(useGrossValue);
    model.addUpdateListener(() -> {
        preferences.setValue(KEY_YEAR, model.getStartYear());
        preferences.setValue(KEY_USE_GROSS_VALUE, model.usesGrossValue());
    });
}
Also used : LocalDate(java.time.LocalDate) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) PostConstruct(javax.annotation.PostConstruct)

Aggregations

CurrencyConverterImpl (name.abuchen.portfolio.money.CurrencyConverterImpl)14 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)9 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)4 Composite (org.eclipse.swt.widgets.Composite)4 Client (name.abuchen.portfolio.model.Client)3 ClientSnapshot (name.abuchen.portfolio.snapshot.ClientSnapshot)3 PortfolioSnapshot (name.abuchen.portfolio.snapshot.PortfolioSnapshot)3 SecurityPosition (name.abuchen.portfolio.snapshot.SecurityPosition)3 Column (name.abuchen.portfolio.ui.util.viewers.Column)3 NameColumn (name.abuchen.portfolio.ui.views.columns.NameColumn)3 NoteColumn (name.abuchen.portfolio.ui.views.columns.NoteColumn)3 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)3 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 BigDecimal (java.math.BigDecimal)2 LocalDate (java.time.LocalDate)2 List (java.util.List)2 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)2 InvestmentPlan (name.abuchen.portfolio.model.InvestmentPlan)2 Transaction (name.abuchen.portfolio.model.Transaction)2