use of name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper in project portfolio by buchen.
the class PerformanceView method addPortfolioColumn.
private void addPortfolioColumn(ShowHideColumnHelper support) {
Column column = new Column(Messages.ColumnPortfolio, SWT.LEFT, 100);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Portfolio portfolio = ((TransactionPair<?>) element).getOwner() instanceof Portfolio ? (Portfolio) ((TransactionPair<?>) element).getOwner() : null;
return portfolio != null ? portfolio.getName() : null;
}
@Override
public Image getImage(Object element) {
Portfolio portfolio = ((TransactionPair<?>) element).getOwner() instanceof Portfolio ? (Portfolio) ((TransactionPair<?>) element).getOwner() : null;
return portfolio != null ? Images.PORTFOLIO.image() : null;
}
});
column.setSorter(ColumnViewerSorter.create(e -> {
Portfolio portfolio = ((TransactionPair<?>) e).getOwner() instanceof Portfolio ? (Portfolio) ((TransactionPair<?>) e).getOwner() : null;
return portfolio != null ? portfolio.getName() : null;
}));
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper in project portfolio by buchen.
the class PerformanceView method createEarningsByAccountsItem.
private void createEarningsByAccountsItem(CTabFolder folder, String title) {
Composite container = new Composite(folder, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
earningsByAccount = new TableViewer(container, SWT.FULL_SELECTION);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
PerformanceView.class.getSimpleName() + "@byaccounts", getPreferenceStore(), earningsByAccount, layout);
Column column = new Column(Messages.ColumnSource, SWT.LEFT, 400);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
GroupEarningsByAccount.Item item = (GroupEarningsByAccount.Item) element;
return item.getAccount().getName();
}
@Override
public Image getImage(Object element) {
return Images.ACCOUNT.image();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(GroupEarningsByAccount.Item.class, "account"));
support.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
GroupEarningsByAccount.Item item = (GroupEarningsByAccount.Item) element;
return Values.Money.format(item.getSum(), getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(GroupEarningsByAccount.Item.class, "sum"));
support.addColumn(column);
support.createColumns();
earningsByAccount.getTable().setHeaderVisible(true);
earningsByAccount.getTable().setLinesVisible(true);
earningsByAccount.setContentProvider(ArrayContentProvider.getInstance());
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(title);
item.setControl(container);
}
use of name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper in project portfolio by buchen.
the class PerformanceView method addSecurityColumn.
private void addSecurityColumn(ShowHideColumnHelper support) {
Column column = new Column(Messages.ColumnSecurity, SWT.LEFT, 250);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Security security = ((TransactionPair<?>) element).getTransaction().getSecurity();
return security != null ? security.getName() : null;
}
@Override
public Image getImage(Object element) {
Security security = ((TransactionPair<?>) element).getTransaction().getSecurity();
return security != null ? Images.SECURITY.image() : null;
}
});
column.setSorter(ColumnViewerSorter.create(e -> {
Security security = ((TransactionPair<?>) e).getTransaction().getSecurity();
return security != null ? security.getName() : null;
}));
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper in project portfolio by buchen.
the class PerformanceView method addTaxesColumn.
private void addTaxesColumn(ShowHideColumnHelper support) {
Column column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
if (t instanceof AccountTransaction) {
AccountTransaction at = (AccountTransaction) t;
switch(at.getType()) {
case TAXES:
return Values.Money.format(at.getMonetaryAmount(), getClient().getBaseCurrency());
case TAX_REFUND:
return Values.Money.format(at.getMonetaryAmount().multiply(-1), getClient().getBaseCurrency());
default:
}
}
return Values.Money.format(t.getUnitSum(Unit.Type.TAX), getClient().getBaseCurrency());
}
});
column.setSorter(ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getUnitSum(Unit.Type.TAX)));
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper in project portfolio by buchen.
the class TransactionsTab method addColumns.
private void addColumns(ShowHideColumnHelper support) {
Column column = new Column(Messages.ColumnDate, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.DateTime.format(((TransactionPair<?>) element).getTransaction().getDateTime());
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getDateTime()).attachTo(column, SWT.UP);
support.addColumn(column);
column = new Column(Messages.ColumnSecurity, SWT.None, 250);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((TransactionPair<?>) element).getTransaction().getSecurity().getName();
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getSecurity().getName()).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
column.setLabelProvider(new SharesLabelProvider() {
@Override
public Long getValue(Object element) {
return ((TransactionPair<?>) element).getTransaction().getShares();
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getShares()).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnGrossValue, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.Money.format(((AccountTransaction) ((TransactionPair<?>) element).getTransaction()).getGrossValue(), client.getBaseCurrency());
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getMonetaryAmount()).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.Money.format(((TransactionPair<?>) element).getTransaction().getUnitSum(Unit.Type.TAX), client.getBaseCurrency());
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getUnitSum(Unit.Type.TAX)).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.Money.format(((TransactionPair<?>) element).getTransaction().getMonetaryAmount(), client.getBaseCurrency());
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getMonetaryAmount()).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnOffsetAccount, SWT.None, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((TransactionPair<?>) element).getOwner().toString();
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getOwner().toString()).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnNote, SWT.None, 200);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((TransactionPair<?>) element).getTransaction().getNote();
}
@Override
public Image getImage(Object element) {
String note = ((TransactionPair<?>) element).getTransaction().getNote();
return note != null && note.length() > 0 ? Images.NOTE.image() : null;
}
});
ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getNote()).attachTo(column);
support.addColumn(column);
}
Aggregations