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); ShowHideColumnHelper support = new ShowHideColumnHelper( SecurityListView.class.getSimpleName() + "@transactions2", // $NON-NLS-1$ transactions, layout); Column column = new Column(Messages.ColumnDate, SWT.None, 80); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { return Values.Date.format(((Transaction) element).getDate()); } }); column.setSorter(ColumnViewerSorter.create(Transaction.class, "date"), SWT.UP); // $NON-NLS-1$ support.addColumn(column); column = new Column(Messages.ColumnTransactionType, SWT.None, 80); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof PortfolioTransaction) return ((PortfolioTransaction) element).getType().toString(); else if (element instanceof AccountTransaction) return ((AccountTransaction) element).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) { return (element instanceof PortfolioTransaction) ? ((PortfolioTransaction) element).getShares() : null; } }); support.addColumn(column); column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { return Values.Amount.format(((Transaction) element).getAmount()); } }); column.setSorter(ColumnViewerSorter.create(Transaction.class, "amount")); // $NON-NLS-1$ support.addColumn(column); column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { return (element instanceof PortfolioTransaction) ? Values.Amount.format(((PortfolioTransaction) element).getActualPurchasePrice()) : null; } }); support.addColumn(column); column = new Column(Messages.ColumnPortfolio, SWT.NONE, 120); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof PortfolioTransaction) { PortfolioTransaction t = (PortfolioTransaction) element; return t.getCrossEntry() != null ? t.getCrossEntry().getEntity(t).toString() : null; } return null; } }); support.addColumn(column); column = new Column(Messages.ColumnOffsetAccount, SWT.NONE, 120); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { if (element instanceof PortfolioTransaction) { PortfolioTransaction t = (PortfolioTransaction) element; return t.getCrossEntry() != null ? t.getCrossEntry().getCrossEntity(t).toString() : null; } return null; } }); support.addColumn(column); support.createColumns(); transactions.getTable().setHeaderVisible(true); transactions.getTable().setLinesVisible(true); transactions.setContentProvider(new SimpleListContentProvider(true)); return container; }
protected Composite createPricesTable(Composite parent) { Composite container = new Composite(parent, SWT.NONE); TableColumnLayout layout = new TableColumnLayout(); container.setLayout(layout); prices = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI); ShowHideColumnHelper support = new ShowHideColumnHelper( SecurityListView.class.getSimpleName() + "@prices", // $NON-NLS-1$ prices, layout); Column column = new Column(Messages.ColumnDate, SWT.None, 80); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { return Values.Date.format(((SecurityPrice) element).getTime()); } }); column.setSorter(ColumnViewerSorter.create(SecurityPrice.class, "time"), SWT.UP); // $NON-NLS-1$ column.setMoveable(false); support.addColumn(column); column = new Column(Messages.ColumnDate, SWT.RIGHT, 80); column.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { return Values.Quote.format(((SecurityPrice) element).getValue()); } }); column.setSorter(ColumnViewerSorter.create(SecurityPrice.class, "value")); // $NON-NLS-1$ column.setMoveable(false); support.addColumn(column); support.createColumns(); prices.getTable().setHeaderVisible(true); prices.getTable().setLinesVisible(true); prices.setContentProvider(new SimpleListContentProvider(true)); new CellEditorFactory(prices, SecurityPrice.class) // .notify( new CellEditorFactory.ModificationListener() { public void onModified(Object element, String property) { markDirty(); Security security = (Security) prices.getData(Security.class.toString()); securities.refresh(security); prices.refresh(element); latest.setInput(security); transactions.setInput(security.getTransactions(getClient())); updateChart(security); } }) // .editable("time") // //$NON-NLS-1$ .amount("value") // //$NON-NLS-1$ .apply(); hookContextMenu( prices.getTable(), new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillPricesContextMenu(manager); } }); return container; }