use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class SecuritiesPerformanceView method createCommonColumns.
private void createCommonColumns() {
// shares held
// $NON-NLS-1$
Column column = new Column("shares", Messages.ColumnSharesOwned, SWT.RIGHT, 80);
column.setLabelProvider(new // NOSONAR
SharesLabelProvider() {
@Override
public Long getValue(Object e) {
return ((SecurityPerformanceRecord) e).getSharesHeld();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "sharesHeld"));
recordColumns.addColumn(column);
// security name
column = new NameColumn();
recordColumns.addColumn(column);
// cost value - fifo
// $NON-NLS-1$
column = new Column("pv", Messages.ColumnPurchaseValue, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnPurchaseValue_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getFifoCost(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCost"));
recordColumns.addColumn(column);
// cost value - moving average
// $NON-NLS-1$
column = new Column("pvmvavg", Messages.ColumnPurchaseValueMovingAverage, SWT.RIGHT, 75);
column.setMenuLabel(Messages.ColumnPurchaseValueMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnPurchaseValueMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getMovingAverageCost(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCost"));
column.setVisible(false);
recordColumns.addColumn(column);
// cost value per share - fifo
// $NON-NLS-1$
column = new Column("pp", Messages.ColumnPurchasePrice, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnPurchasePrice_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Quote.format(((SecurityPerformanceRecord) r).getFifoCostPerSharesHeld(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
recordColumns.addColumn(column);
// cost value per share - moving average
// $NON-NLS-1$
column = new Column("ppmvavg", Messages.ColumnPurchasePriceMovingAverage, SWT.RIGHT, 75);
column.setMenuLabel(Messages.ColumnPurchasePriceMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnPurchasePriceMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Quote.format(((SecurityPerformanceRecord) r).getMovingAverageCostPerSharesHeld(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCostPerSharesHeld"));
column.setVisible(false);
recordColumns.addColumn(column);
// latest / current quote
// $NON-NLS-1$
column = new Column("quote", Messages.ColumnQuote, SWT.RIGHT, 75);
column.setDescription(Messages.ColumnQuote_DescriptionEndOfReportingPeriod);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
return Values.Quote.format(record.getQuote(), getClient().getBaseCurrency());
}
@Override
public String getToolTipText(Object element) {
SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
return MessageFormat.format(Messages.TooltipQuoteAtDate, getText(element), Values.Date.format(record.getLatestSecurityPrice().getDate()));
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
recordColumns.addColumn(column);
// market value
// $NON-NLS-1$
column = new Column("mv", Messages.ColumnMarketValue, SWT.RIGHT, 75);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getMarketValue(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "marketValue"));
recordColumns.addColumn(column);
// fees paid
// $NON-NLS-1$
column = new Column("fees", Messages.ColumnFees, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnFees_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getFees(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fees"));
column.setVisible(false);
recordColumns.addColumn(column);
// taxes paid
// $NON-NLS-1$
column = new Column("taxes", Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Money.format(((SecurityPerformanceRecord) r).getTaxes(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "taxes"));
column.setVisible(false);
recordColumns.addColumn(column);
// isin
column = new IsinColumn();
column.getEditingSupport().addListener(new MarkDirtyListener(this));
column.setVisible(false);
recordColumns.addColumn(column);
// note
column = new NoteColumn();
column.getEditingSupport().addListener(new MarkDirtyListener(this));
column.setVisible(false);
recordColumns.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class SecuritiesPerformanceView method createBottomTable.
@Override
protected // NOSONAR
void createBottomTable(// NOSONAR
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);
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()));
latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabTransactions);
Composite container = new Composite(folder, SWT.NONE);
item.setControl(container);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
folder.setSelection(0);
transactions = new TableViewer(container, SWT.FULL_SELECTION);
ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
SecuritiesPerformanceView.class.getSimpleName() + "@bottom4", // $NON-NLS-1$
getPreferenceStore(), transactions, layout);
// date
Column column = new Column(Messages.ColumnDate, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Transaction t = (Transaction) e;
return Values.DateTime.format(t.getDateTime());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Transaction.class, "dateTime"), SWT.DOWN);
support.addColumn(column);
// transaction type
column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction)
return ((PortfolioTransaction) t).getType().toString();
else if (t instanceof AccountTransaction)
return ((AccountTransaction) t).getType().toString();
else if (t instanceof DividendTransaction)
return AccountTransaction.Type.DIVIDENDS.toString();
else
return Messages.LabelQuote;
}
});
support.addColumn(column);
// shares
column = new Column(Messages.ColumnShares, SWT.None, 80);
column.setLabelProvider(new // NOSONAR
SharesLabelProvider() {
@Override
public // NOSONAR
Long getValue(// NOSONAR
Object t) {
if (t instanceof PortfolioTransaction)
return ((PortfolioTransaction) t).getShares();
else if (t instanceof DividendInitialTransaction)
return ((DividendInitialTransaction) t).getPosition().getShares();
else if (t instanceof DividendFinalTransaction)
return ((DividendFinalTransaction) t).getPosition().getShares();
else if (t instanceof DividendTransaction)
return ((DividendTransaction) t).getShares() != 0L ? ((DividendTransaction) t).getShares() : null;
else
return null;
}
});
support.addColumn(column);
// dividend amount
column = new Column(Messages.ColumnDividendPayment, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnGrossDividend);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Money.format(((DividendTransaction) t).getGrossValue(), getClient().getBaseCurrency());
else
return null;
}
});
support.addColumn(column);
// dividend per share
column = new Column(Messages.ColumnDividendPerShare, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.AmountFraction.formatNonZero(((DividendTransaction) t).getDividendPerShare());
else
return null;
}
});
support.addColumn(column);
// dividend per share
column = new Column(Messages.ColumnPersonalDividendYield, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPersonalDividendYield_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYield());
else
return null;
}
});
support.addColumn(column);
// dividend per share (moving average)
column = new Column(Messages.ColumnPersonalDividendYieldMovingAverage, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPersonalDividendYieldMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYieldMovingAverage());
else
return null;
}
});
support.addColumn(column);
// einstandskurs / bewertung
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return null;
else
return Values.Money.format(((Transaction) t).getMonetaryAmount(), getClient().getBaseCurrency());
}
});
support.addColumn(column);
// purchase quote
column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction) {
PortfolioTransaction p = (PortfolioTransaction) t;
return Values.Quote.format(p.getGrossPricePerShare(), getClient().getBaseCurrency());
} else
return null;
}
});
support.addColumn(column);
// gegenkonto
column = new Column(Messages.ColumnAccount, SWT.None, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction) {
PortfolioTransaction p = (PortfolioTransaction) t;
return p.getCrossEntry() != null ? p.getCrossEntry().getCrossOwner(p).toString() : null;
} else if (t instanceof DividendTransaction) {
return ((DividendTransaction) t).getAccount().getName();
} else {
return null;
}
}
});
support.addColumn(column);
// note
// $NON-NLS-1$
column = new Column("note", Messages.ColumnNote, SWT.LEFT, 22);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return ((Transaction) r).getNote();
}
@Override
public Image getImage(Object r) {
String note = ((Transaction) r).getNote();
return note != null && note.length() > 0 ? Images.NOTE.image() : null;
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Transaction.class, "note"));
support.addColumn(column);
support.createColumns();
transactions.getTable().setHeaderVisible(true);
transactions.getTable().setLinesVisible(true);
transactions.setContentProvider(ArrayContentProvider.getInstance());
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class SecuritiesPerformanceView method createRiskColumns.
private void createRiskColumns() {
// $NON-NLS-1$
Column column = new Column("mdd", Messages.ColumnMaxDrawdown, SWT.RIGHT, 60);
column.setMenuLabel(Messages.LabelMaxDrawdown);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Percent2.formatNonZero(((SecurityPerformanceRecord) r).getMaxDrawdown());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "maxDrawdown"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("mddduration", Messages.ColumnMaxDrawdownDuration, SWT.RIGHT, 60);
column.setMenuLabel(Messages.LabelMaxDrawdownDuration);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return String.valueOf(((SecurityPerformanceRecord) r).getMaxDrawdownDuration());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "maxDrawdownDuration"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("vola", Messages.LabelVolatility, SWT.RIGHT, 80);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Percent2.format(((SecurityPerformanceRecord) r).getVolatility());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "volatility"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("semivola", Messages.LabelSemiVolatility, SWT.RIGHT, 80);
column.setGroupLabel(Messages.LabelRiskIndicators);
column.setVisible(false);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return Values.Percent2.format(((SecurityPerformanceRecord) r).getSemiVolatility());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "semiVolatility"));
recordColumns.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class SecuritiesPerformanceView method createAdditionalColumns.
private void createAdditionalColumns() {
for (Taxonomy taxonomy : getClient().getTaxonomies()) {
Column column = new TaxonomyColumn(taxonomy);
column.setVisible(false);
recordColumns.addColumn(column);
}
//
getClient().getSettings().getAttributeTypes().filter(//
a -> a.supports(Security.class)).forEach(attribute -> {
Column column = new AttributeColumn(attribute);
column.setVisible(false);
column.setEditingSupport(null);
recordColumns.addColumn(column);
});
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class SecuritiesPerformanceView method addPerformanceColumns.
private void addPerformanceColumns() {
// $NON-NLS-1$
Column column = new Column("twror", Messages.ColumnTWROR, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnTWROR_Description);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getTrueTimeWeightedRateOfReturn()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "trueTimeWeightedRateOfReturn"));
recordColumns.addColumn(column);
// internal rate of return
// $NON-NLS-1$
column = new Column("izf", Messages.ColumnIRR, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnIRR_MenuLabel);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getIrr()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "irr"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgains", Messages.ColumnCapitalGains, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGains_Description);
column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getCapitalGainsOnHoldings(), getClient().getBaseCurrency()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldings"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgains%", Messages.ColumnCapitalGainsPercent, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsPercent_Description);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getCapitalGainsOnHoldingsPercent()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsPercent"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg", Messages.ColumnCapitalGainsMovingAverage, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnCapitalGainsMovingAverage_MenuLabel);
column.setDescription(Messages.ColumnCapitalGainsMovingAverage_Description);
column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getCapitalGainsOnHoldingsMovingAverage(), getClient().getBaseCurrency()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsMovingAverage"));
recordColumns.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg%", Messages.ColumnCapitalGainsMovingAveragePercent, SWT.RIGHT, 80);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setMenuLabel(Messages.ColumnCapitalGainsMovingAveragePercent_MenuLabel);
column.setDescription(Messages.ColumnCapitalGainsMovingAveragePercent_Description);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getCapitalGainsOnHoldingsMovingAveragePercent()));
column.setVisible(false);
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsMovingAveragePercent"));
recordColumns.addColumn(column);
// delta
// $NON-NLS-1$
column = new Column("delta", Messages.ColumnAbsolutePerformance, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnAbsolutePerformance_Description);
column.setMenuLabel(Messages.ColumnAbsolutePerformance_MenuLabel);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getDelta(), getClient().getBaseCurrency()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "delta"));
recordColumns.addColumn(column);
// delta percent
// $NON-NLS-1$
column = new Column("delta%", Messages.ColumnAbsolutePerformancePercent, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnAbsolutePerformancePercent_Description);
column.setMenuLabel(Messages.ColumnAbsolutePerformancePercent_MenuLabel);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getDeltaPercent()));
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "deltaPercent"));
column.setVisible(false);
recordColumns.addColumn(column);
}
Aggregations