use of name.abuchen.portfolio.ui.views.columns.CurrencyColumn in project portfolio by buchen.
the class SecuritiesTable method addMasterDataColumns.
private void addMasterDataColumns() {
// $NON-NLS-1$
Column column = new Column("0", Messages.ColumnName, SWT.LEFT, 400);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return ((Security) e).getName();
}
@Override
public Image getImage(Object e) {
return ((Security) e).isRetired() ? Images.SECURITY_RETIRED.image() : Images.SECURITY.image();
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(Security.class, "name").attachTo(column, SWT.DOWN);
// $NON-NLS-1$
new StringEditingSupport(Security.class, "name").setMandatory(true).addListener(this).attachTo(column);
support.addColumn(column);
column = new NoteColumn();
column.getEditingSupport().addListener(this);
support.addColumn(column);
// $NON-NLS-1$
column = new IsinColumn("1");
column.getEditingSupport().addListener(this);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("2", Messages.ColumnTicker, SWT.LEFT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return ((Security) e).getTickerSymbol();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Security.class, "tickerSymbol"));
// $NON-NLS-1$
new StringEditingSupport(Security.class, "tickerSymbol").addListener(this).attachTo(column);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("7", Messages.ColumnWKN, SWT.LEFT, 60);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return ((Security) e).getWkn();
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Security.class, "wkn"));
// $NON-NLS-1$
new StringEditingSupport(Security.class, "wkn").addListener(this).attachTo(column);
column.setVisible(false);
support.addColumn(column);
column = new CurrencyColumn();
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("8", Messages.ColumnRetired, SWT.LEFT, 40);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
// $NON-NLS-1$
return "";
}
@Override
public Image getImage(Object e) {
return ((Security) e).isRetired() ? Images.CHECK.image() : null;
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Security.class, "retired"));
// $NON-NLS-1$
new BooleanEditingSupport(Security.class, "retired").addListener(this).attachTo(column);
column.setVisible(false);
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.views.columns.CurrencyColumn in project portfolio by buchen.
the class AccountListView method createTopTable.
// //////////////////////////////////////////////////////////////
// top table: accounts
// //////////////////////////////////////////////////////////////
@Override
protected void createTopTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
accounts = new TableViewer(container, SWT.FULL_SELECTION);
ColumnEditingSupport.prepare(accounts);
accountColumns = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
AccountListView.class.getSimpleName() + "@top2", getPreferenceStore(), accounts, layout);
// $NON-NLS-1$
Column column = new NameColumn("0", Messages.ColumnAccount, SWT.None, 150);
column.setLabelProvider(new // NOSONAR
NameColumnLabelProvider() {
@Override
public Color getForeground(Object e) {
boolean isRetired = ((Account) e).isRetired();
return isRetired ? Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY) : null;
}
});
column.getEditingSupport().addListener(this);
accountColumns.addColumn(column);
column = new Column(Messages.ColumnBalance, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnBalance_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return Values.Amount.format(((Account) e).getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX)));
}
});
ColumnViewerSorter.create(o -> ((Account) o).getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX))).attachTo(column);
accountColumns.addColumn(column);
column = new CurrencyColumn();
column.setEditingSupport(new CurrencyEditingSupport() {
@Override
public boolean canEdit(Object element) {
return ((Account) element).getTransactions().isEmpty();
}
});
accountColumns.addColumn(column);
column = new NoteColumn();
column.getEditingSupport().addListener(this);
accountColumns.addColumn(column);
accountColumns.createColumns();
accounts.getTable().setHeaderVisible(true);
accounts.getTable().setLinesVisible(true);
accounts.setContentProvider(ArrayContentProvider.getInstance());
resetInput();
accounts.refresh();
accounts.addSelectionChangedListener(event -> {
Account account = (Account) ((IStructuredSelection) event.getSelection()).getFirstElement();
updateOnAccountSelected(account);
transactions.setData(Account.class.toString(), account);
transactions.setInput(account != null ? account.getTransactions() : new ArrayList<AccountTransaction>(0));
transactions.refresh();
});
hookContextMenu(accounts.getTable(), this::fillAccountsContextMenu);
}
Aggregations