use of org.eclipse.jface.layout.TableColumnLayout 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;
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class SecurityListView method createTransactionTable.
// //////////////////////////////////////////////////////////////
// tab item: transactions
// //////////////////////////////////////////////////////////////
protected Composite createTransactionTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
transactions = new TableViewer(container, SWT.FULL_SELECTION);
ColumnViewerToolTipSupport.enableFor(transactions, ToolTip.NO_RECREATE);
ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
SecurityListView.class.getSimpleName() + "@transactions4", // $NON-NLS-1$
getPreferenceStore(), // $NON-NLS-1$
transactions, layout);
Column column = new Column(Messages.ColumnDate, SWT.None, 100);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.DateTime.format(((TransactionPair<?>) element).getTransaction().getDateTime());
}
});
column.setSorter(ColumnViewerSorter.create((o1, o2) -> ((TransactionPair<?>) o1).getTransaction().getDateTime().compareTo(((TransactionPair<?>) o2).getTransaction().getDateTime())), SWT.UP);
support.addColumn(column);
column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
if (t instanceof PortfolioTransaction)
return ((PortfolioTransaction) t).getType().toString();
else if (t instanceof AccountTransaction)
return ((AccountTransaction) t).getType().toString();
else
return null;
}
});
support.addColumn(column);
column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
column.setLabelProvider(new SharesLabelProvider() {
@Override
public Long getValue(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
if (t instanceof PortfolioTransaction) {
return ((PortfolioTransaction) t).getShares();
} else if (t instanceof AccountTransaction) {
long shares = ((AccountTransaction) t).getShares();
return shares != 0 ? shares : null;
}
return null;
}
});
support.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
return Values.Money.format(t.getMonetaryAmount(), getClient().getBaseCurrency());
}
});
column.setSorter(ColumnViewerSorter.create((o1, o2) -> {
long a1 = ((TransactionPair<?>) o1).getTransaction().getAmount();
long a2 = ((TransactionPair<?>) o2).getTransaction().getAmount();
return a1 > a2 ? 1 : a1 < a2 ? -1 : 0;
}));
support.addColumn(column);
column = new Column(Messages.ColumnPerShare, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPerShare_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
if (t instanceof PortfolioTransaction) {
return Values.Quote.format(((PortfolioTransaction) t).getGrossPricePerShare(), getClient().getBaseCurrency());
} else if (t instanceof AccountTransaction) {
long shares = ((AccountTransaction) t).getShares();
if (shares != 0) {
long perShare = Math.round(((AccountTransaction) t).getGrossValueAmount() * Values.Share.divider() * Values.Quote.factorToMoney() / shares);
return Values.Quote.format(Quote.of(t.getCurrencyCode(), perShare));
}
}
return null;
}
});
support.addColumn(column);
column = new Column(Messages.ColumnFees, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnFees_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
return Values.Money.format(t.getUnitSum(Unit.Type.FEE), getClient().getBaseCurrency());
}
});
support.addColumn(column);
column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnTaxes_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Transaction t = ((TransactionPair<?>) element).getTransaction();
return Values.Money.format(t.getUnitSum(Unit.Type.TAX), getClient().getBaseCurrency());
}
});
support.addColumn(column);
column = new Column(Messages.ColumnPortfolio, SWT.NONE, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
TransactionOwner<?> owner = ((TransactionPair<?>) element).getOwner();
if (owner instanceof Portfolio)
return owner.toString();
return null;
}
});
support.addColumn(column);
column = new Column(Messages.ColumnOffsetAccount, SWT.NONE, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
TransactionPair<?> pair = (TransactionPair<?>) element;
Transaction t = pair.getTransaction();
if (t instanceof PortfolioTransaction)
return t.getCrossEntry() != null ? t.getCrossEntry().getCrossOwner(t).toString() : null;
else
return pair.getOwner().toString();
}
});
support.addColumn(column);
column = new NoteColumn();
column.setEditingSupport(null);
support.addColumn(column);
support.createColumns();
transactions.getTable().setHeaderVisible(true);
transactions.getTable().setLinesVisible(true);
transactions.setContentProvider(ArrayContentProvider.getInstance());
hookContextMenu(transactions.getControl(), this::transactionMenuAboutToShow);
hookKeyListener();
return container;
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class ExchangeRatesListView method createTopTable.
@Override
protected void createTopTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
TableViewer indeces = new TableViewer(container, SWT.FULL_SELECTION);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
ExchangeRatesListView.class.getSimpleName() + "@top2", getPreferenceStore(), indeces, layout);
Column column = new Column(Messages.ColumnBaseCurrency, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((ExchangeRateTimeSeries) element).getBaseCurrency();
}
});
// $NON-NLS-1$ //$NON-NLS-2$
ColumnViewerSorter.create(ExchangeRateTimeSeries.class, "baseCurrency", "termCurrency").attachTo(column, SWT.DOWN);
support.addColumn(column);
column = new Column(Messages.ColumnTermCurrency, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((ExchangeRateTimeSeries) element).getTermCurrency();
}
});
// $NON-NLS-1$ //$NON-NLS-2$
ColumnViewerSorter.create(ExchangeRateTimeSeries.class, "termCurrency", "baseCurrency").attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnCurrencyProvider, SWT.None, 150);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((ExchangeRateTimeSeries) element).getProvider().getName();
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(ExchangeRateTimeSeries.class, "provider").attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnDateLatestExchangeRate, SWT.None, 150);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ExchangeRateTimeSeries series = (ExchangeRateTimeSeries) element;
List<ExchangeRate> rates = series.getRates();
return rates.isEmpty() ? null : Values.Date.format(rates.get(rates.size() - 1).getTime());
}
});
ColumnViewerSorter.create(element -> {
ExchangeRateTimeSeries series = (ExchangeRateTimeSeries) element;
List<ExchangeRate> rates = series.getRates();
return rates.isEmpty() ? null : rates.get(rates.size() - 1).getTime();
}).attachTo(column);
support.addColumn(column);
support.createColumns();
indeces.getTable().setHeaderVisible(true);
indeces.getTable().setLinesVisible(true);
indeces.setContentProvider(ArrayContentProvider.getInstance());
indeces.setInput(providerFactory.getAvailableTimeSeries());
indeces.refresh();
indeces.addSelectionChangedListener(event -> refreshChart((ExchangeRateTimeSeries) ((IStructuredSelection) event.getSelection()).getFirstElement()));
}
use of org.eclipse.jface.layout.TableColumnLayout 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 org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class PortfolioListView method createTopTable.
// //////////////////////////////////////////////////////////////
// top table: accounts
// //////////////////////////////////////////////////////////////
protected void createTopTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
portfolios = new TableViewer(container, SWT.FULL_SELECTION);
ColumnEditingSupport.prepare(portfolios);
portfolioColumns = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
PortfolioListView.class.getSimpleName() + "@top2", getPreferenceStore(), portfolios, layout);
// $NON-NLS-1$
Column column = new NameColumn("0", Messages.ColumnPortfolio, SWT.None, 100);
column.setLabelProvider(new NameColumnLabelProvider() {
@Override
public Color getForeground(Object e) {
boolean isRetired = ((Portfolio) e).isRetired();
return isRetired ? Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY) : null;
}
});
column.getEditingSupport().addListener(this);
portfolioColumns.addColumn(column);
column = new Column(Messages.ColumnReferenceAccount, SWT.None, 160);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Portfolio p = (Portfolio) e;
return p.getReferenceAccount() != null ? p.getReferenceAccount().getName() : null;
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(Portfolio.class, "referenceAccount").attachTo(column);
// $NON-NLS-1$
new ListEditingSupport(Portfolio.class, "referenceAccount", getClient().getAccounts()).addListener(this).attachTo(column);
portfolioColumns.addColumn(column);
column = new NoteColumn();
column.getEditingSupport().addListener(this);
portfolioColumns.addColumn(column);
portfolioColumns.createColumns();
portfolios.getTable().setHeaderVisible(true);
portfolios.getTable().setLinesVisible(true);
portfolios.setContentProvider(ArrayContentProvider.getInstance());
setInput();
portfolios.addSelectionChangedListener(event -> {
Portfolio portfolio = (Portfolio) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (portfolio != null) {
transactions.setInput(portfolio, portfolio.getTransactions());
transactions.refresh();
CurrencyConverter converter = new CurrencyConverterImpl(factory, portfolio.getReferenceAccount().getCurrencyCode());
statementOfAssets.setInput(PortfolioSnapshot.create(portfolio, converter, LocalDate.now()));
} else {
transactions.setInput(null, null);
transactions.refresh();
statementOfAssets.setInput((PortfolioSnapshot) null);
}
});
hookContextMenu(portfolios.getTable(), this::fillPortfolioContextMenu);
}
Aggregations