Search in sources :

Example 1 with SecurityEvent

use of name.abuchen.portfolio.model.SecurityEvent in project portfolio by buchen.

the class SecurityListView method createEventsTable.

// //////////////////////////////////////////////////////////////
// tab item: transactions
// //////////////////////////////////////////////////////////////
protected Composite createEventsTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    events = new TableViewer(container, SWT.FULL_SELECTION);
    ShowHideColumnHelper support = new // $NON-NLS-1$
    ShowHideColumnHelper(// $NON-NLS-1$
    SecurityListView.class.getSimpleName() + "@events", getPreferenceStore(), events, layout);
    Column column = new Column(Messages.ColumnDate, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return Values.Date.format(((SecurityEvent) element).getDate());
        }
    });
    column.setSorter(ColumnViewerSorter.create(e -> ((SecurityEvent) e).getDate()), SWT.UP);
    support.addColumn(column);
    column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((SecurityEvent) element).getType().toString();
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnDetails, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((SecurityEvent) element).getDetails();
        }
    });
    support.addColumn(column);
    support.createColumns();
    events.getTable().setHeaderVisible(true);
    events.getTable().setLinesVisible(true);
    events.setContentProvider(ArrayContentProvider.getInstance());
    return container;
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) ToolBar(org.eclipse.swt.widgets.ToolBar) TransactionOwner(name.abuchen.portfolio.model.TransactionOwner) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) KeyEvent(org.eclipse.swt.events.KeyEvent) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SearchYahooWizardDialog(name.abuchen.portfolio.ui.wizards.security.SearchYahooWizardDialog) Separator(org.eclipse.jface.action.Separator) Text(org.eclipse.swt.widgets.Text) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) Account(name.abuchen.portfolio.model.Account) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) Predicate(java.util.function.Predicate) SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Security(name.abuchen.portfolio.model.Security) ToolItem(org.eclipse.swt.widgets.ToolItem) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) Dates(name.abuchen.portfolio.util.Dates) Colors(name.abuchen.portfolio.ui.util.Colors) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) Pattern(java.util.regex.Pattern) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) SecurityEvent(name.abuchen.portfolio.model.SecurityEvent) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) Quote(name.abuchen.portfolio.money.Quote) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) DateEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateEditingSupport) Images(name.abuchen.portfolio.ui.Images) ConvertBuySellToDeliveryAction(name.abuchen.portfolio.ui.views.actions.ConvertBuySellToDeliveryAction) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Messages(name.abuchen.portfolio.ui.Messages) ConvertDeliveryToBuySellAction(name.abuchen.portfolio.ui.views.actions.ConvertDeliveryToBuySellAction) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Portfolio(name.abuchen.portfolio.model.Portfolio) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TransactionPair(name.abuchen.portfolio.model.TransactionPair) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) Unit(name.abuchen.portfolio.model.Transaction.Unit) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) ToolTip(org.eclipse.jface.window.ToolTip) SWTHelper(name.abuchen.portfolio.ui.util.SWTHelper) Collections(java.util.Collections) PortfolioTransferEntry(name.abuchen.portfolio.model.PortfolioTransferEntry) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) SecurityEvent(name.abuchen.portfolio.model.SecurityEvent) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with SecurityEvent

use of name.abuchen.portfolio.model.SecurityEvent in project portfolio by buchen.

the class StockSplitModel method applyChanges.

@Override
public void applyChanges() {
    // $NON-NLS-1$
    SecurityEvent event = new SecurityEvent(exDate, SecurityEvent.Type.STOCK_SPLIT, newShares + ":" + oldShares);
    security.addEvent(event);
    if (isChangeTransactions()) {
        List<TransactionPair<?>> transactions = security.getTransactions(getClient());
        for (TransactionPair<?> pair : transactions) {
            Transaction t = pair.getTransaction();
            if (t.getDateTime().toLocalDate().isBefore(exDate))
                t.setShares(t.getShares() * newShares / oldShares);
        }
    }
    if (isChangeHistoricalQuotes()) {
        List<SecurityPrice> quotes = security.getPrices();
        for (SecurityPrice p : quotes) {
            if (p.getDate().isBefore(exDate))
                p.setValue(p.getValue() * oldShares / newShares);
        }
    }
}
Also used : TransactionPair(name.abuchen.portfolio.model.TransactionPair) SecurityEvent(name.abuchen.portfolio.model.SecurityEvent) Transaction(name.abuchen.portfolio.model.Transaction) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice)

Aggregations

SecurityEvent (name.abuchen.portfolio.model.SecurityEvent)2 SecurityPrice (name.abuchen.portfolio.model.SecurityPrice)2 Transaction (name.abuchen.portfolio.model.Transaction)2 TransactionPair (name.abuchen.portfolio.model.TransactionPair)2 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Pattern (java.util.regex.Pattern)1 Inject (javax.inject.Inject)1 Account (name.abuchen.portfolio.model.Account)1 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)1 Portfolio (name.abuchen.portfolio.model.Portfolio)1 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)1 PortfolioTransferEntry (name.abuchen.portfolio.model.PortfolioTransferEntry)1 Security (name.abuchen.portfolio.model.Security)1 Unit (name.abuchen.portfolio.model.Transaction.Unit)1