use of name.abuchen.portfolio.ui.util.viewers.StringEditingSupport 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.util.viewers.StringEditingSupport in project portfolio by buchen.
the class PortfolioTransactionsViewer method addColumns.
private void addColumns() {
Column column = new Column(Messages.ColumnDate, SWT.None, 100);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
return Values.DateTime.format(((PortfolioTransaction) element).getDateTime());
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "dateTime").attachTo(column, SWT.DOWN);
// $NON-NLS-1$
new DateTimeEditingSupport(PortfolioTransaction.class, "dateTime").addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
return ((PortfolioTransaction) element).getType().toString();
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "type").attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnSecurity, SWT.None, 250);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
PortfolioTransaction t = (PortfolioTransaction) element;
return t.getSecurity() != null ? String.valueOf(t.getSecurity()) : null;
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "security").attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
column.setLabelProvider(new SharesLabelProvider() {
private TransactionLabelProvider colors = new TransactionLabelProvider();
@Override
public Long getValue(Object element) {
return ((PortfolioTransaction) element).getShares();
}
@Override
public Color getForeground(Object element) {
return colors.getForeground(element);
}
@Override
public Color getBackground(Object element) {
return colors.getBackground(element);
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "shares").attachTo(column);
// $NON-NLS-1$
new ValueEditingSupport(PortfolioTransaction.class, "shares", Values.Share).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
PortfolioTransaction t = (PortfolioTransaction) element;
return t.getShares() != 0 ? Values.Quote.format(t.getGrossPricePerShare(), owner.getClient().getBaseCurrency()) : null;
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "grossPricePerShare").attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
return Values.Money.format(((PortfolioTransaction) element).getGrossValue(), owner.getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "grossValueAmount").attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnFees, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
PortfolioTransaction t = (PortfolioTransaction) element;
return Values.Money.format(t.getUnitSum(Transaction.Unit.Type.FEE), owner.getClient().getBaseCurrency());
}
});
support.addColumn(column);
column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
PortfolioTransaction t = (PortfolioTransaction) element;
return Values.Money.format(t.getUnitSum(Transaction.Unit.Type.TAX), owner.getClient().getBaseCurrency());
}
});
support.addColumn(column);
column = new Column(Messages.ColumnNetValue, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object element) {
PortfolioTransaction t = (PortfolioTransaction) element;
return Values.Money.format(t.getMonetaryAmount(), owner.getClient().getBaseCurrency());
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "amount").attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnOffsetAccount, SWT.None, 120);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object e) {
PortfolioTransaction t = (PortfolioTransaction) e;
return t.getCrossEntry() != null ? t.getCrossEntry().getCrossOwner(t).toString() : null;
}
});
support.addColumn(column);
column = new Column(Messages.ColumnNote, SWT.None, 200);
column.setLabelProvider(new TransactionLabelProvider() {
@Override
public String getText(Object e) {
return ((PortfolioTransaction) e).getNote();
}
@Override
public Image getImage(Object e) {
String note = ((PortfolioTransaction) e).getNote();
return note != null && note.length() > 0 ? Images.NOTE.image() : null;
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(PortfolioTransaction.class, "note").attachTo(column);
// $NON-NLS-1$
new StringEditingSupport(PortfolioTransaction.class, "note").addListener(this).attachTo(column);
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.StringEditingSupport in project portfolio by buchen.
the class AttributeListTab method addColumns.
private void addColumns(ShowHideColumnHelper support) {
Column column = new Column(Messages.ColumnName, SWT.None, 250);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((AttributeType) element).getName();
}
@Override
public Image getImage(Object element) {
return Images.TEXT.image();
}
});
// $NON-NLS-1$
new StringEditingSupport(AttributeType.class, "name").addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnColumnLabel, SWT.None, 150);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((AttributeType) element).getColumnLabel();
}
});
// $NON-NLS-1$
new StringEditingSupport(AttributeType.class, "columnLabel").addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnFieldType, SWT.None, 150);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return AttributeFieldType.of((AttributeType) element).toString();
}
});
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.StringEditingSupport in project portfolio by buchen.
the class BookmarksListTab method createTab.
@Override
public CTabItem createTab(CTabFolder folder) {
Composite container = new Composite(folder, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
bookmarks = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnEditingSupport.prepare(bookmarks);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
BookmarksListTab.class.getSimpleName() + "@bottom", preferences, bookmarks, layout);
// Create Column for Bookmark
Column column = new Column(Messages.BookmarksListView_bookmark, SWT.None, 150);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Bookmark) element).getLabel();
}
@Override
public Image getImage(Object element) {
return Images.TEXT.image();
}
});
// $NON-NLS-1$
new StringEditingSupport(Bookmark.class, "label").addListener(this).attachTo(column);
support.addColumn(column);
// Create Column for URL
column = new Column(Messages.BookmarksListView_url, SWT.None, 500);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Bookmark) element).getPattern();
}
});
// $NON-NLS-1$
new StringEditingSupport(Bookmark.class, "pattern").addListener(this).attachTo(column);
support.addColumn(column);
support.createColumns();
bookmarks.getTable().setHeaderVisible(true);
bookmarks.getTable().setLinesVisible(true);
bookmarks.setContentProvider(ArrayContentProvider.getInstance());
bookmarks.setInput(client.getSettings().getBookmarks());
bookmarks.refresh();
new ContextMenu(bookmarks.getTable(), this::fillContextMenu).hook();
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.BookmarksListView_title);
item.setControl(container);
return item;
}
use of name.abuchen.portfolio.ui.util.viewers.StringEditingSupport in project portfolio by buchen.
the class AccountListView method createTransactionTable.
protected Control createTransactionTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
transactions = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnViewerToolTipSupport.enableFor(transactions, ToolTip.NO_RECREATE);
ColumnEditingSupport.prepare(transactions);
transactionsColumns = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
AccountListView.class.getSimpleName() + "@bottom5", getPreferenceStore(), transactions, layout);
Column column = new Column(Messages.ColumnDate, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return Values.DateTime.format(((AccountTransaction) e).getDateTime());
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
});
ColumnViewerSorter.create(new AccountTransaction.ByDateAmountTypeAndHashCode()).attachTo(column, SWT.DOWN);
// $NON-NLS-1$
new DateTimeEditingSupport(AccountTransaction.class, "dateTime").addListener(this).attachTo(column);
transactionsColumns.addColumn(column);
column = new Column(Messages.ColumnTransactionType, SWT.None, 100);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
AccountTransaction t = (AccountTransaction) e;
return t.getType().toString();
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "type"));
transactionsColumns.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
AccountTransaction t = (AccountTransaction) e;
long v = t.getAmount();
if (t.getType().isDebit())
v = -v;
return Values.Money.format(Money.of(t.getCurrencyCode(), v), getClient().getBaseCurrency());
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "amount"));
transactionsColumns.addColumn(column);
column = new Column(Messages.Balance, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Money balance = transaction2balance.get(e);
return balance != null ? Values.Money.format(balance, getClient().getBaseCurrency()) : null;
}
});
column.setSorter(ColumnViewerSorter.create(new AccountTransaction.ByDateAmountTypeAndHashCode()));
transactionsColumns.addColumn(column);
column = new Column(Messages.ColumnSecurity, SWT.None, 250);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
AccountTransaction t = (AccountTransaction) e;
return t.getSecurity() != null ? String.valueOf(t.getSecurity()) : null;
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "security"));
transactionsColumns.addColumn(column);
column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
column.setLabelProvider(new SharesLabelProvider() {
@Override
public Long getValue(Object e) {
AccountTransaction t = (AccountTransaction) e;
if (t.getCrossEntry() instanceof BuySellEntry) {
return ((BuySellEntry) t.getCrossEntry()).getPortfolioTransaction().getShares();
} else if (t.getType() == Type.DIVIDENDS && t.getShares() != 0) {
return t.getShares();
} else {
return null;
}
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
});
new // $NON-NLS-1$
ValueEditingSupport(// $NON-NLS-1$
AccountTransaction.class, // $NON-NLS-1$
"shares", // $NON-NLS-1$
Values.Share) {
@Override
public boolean canEdit(Object element) {
AccountTransaction t = (AccountTransaction) element;
return t.getType() == AccountTransaction.Type.DIVIDENDS;
}
}.addListener(this).attachTo(column);
transactionsColumns.addColumn(column);
column = new Column(Messages.ColumnPerShare, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPerShare_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
AccountTransaction t = (AccountTransaction) e;
if (t.getCrossEntry() instanceof BuySellEntry) {
PortfolioTransaction pt = ((BuySellEntry) t.getCrossEntry()).getPortfolioTransaction();
return Values.Quote.format(pt.getGrossPricePerShare(), getClient().getBaseCurrency());
} else if (t.getType() == Type.DIVIDENDS && t.getShares() != 0) {
long dividendPerShare = Math.round(t.getAmount() * Values.Share.divider() * Values.Quote.factorToMoney() / t.getShares());
return Values.Quote.format(Quote.of(t.getCurrencyCode(), dividendPerShare), getClient().getBaseCurrency());
} else {
return null;
}
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
});
transactionsColumns.addColumn(column);
column = new Column(Messages.ColumnOffsetAccount, SWT.None, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
AccountTransaction t = (AccountTransaction) e;
return t.getCrossEntry() != null ? t.getCrossEntry().getCrossOwner(t).toString() : null;
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
});
transactionsColumns.addColumn(column);
column = new Column(Messages.ColumnNote, SWT.None, 200);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
return ((AccountTransaction) e).getNote();
}
@Override
public Color getForeground(Object element) {
return colorFor((AccountTransaction) element);
}
@Override
public Image getImage(Object e) {
String note = ((AccountTransaction) e).getNote();
return note != null && note.length() > 0 ? Images.NOTE.image() : null;
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(AccountTransaction.class, "note").attachTo(column);
// $NON-NLS-1$
new StringEditingSupport(AccountTransaction.class, "note").addListener(this).attachTo(column);
transactionsColumns.addColumn(column);
transactionsColumns.createColumns();
transactions.getTable().setHeaderVisible(true);
transactions.getTable().setLinesVisible(true);
transactions.setContentProvider(ArrayContentProvider.getInstance());
hookContextMenu(transactions.getTable(), this::fillTransactionsContextMenu);
hookKeyListener();
return container;
}
Aggregations