use of name.abuchen.portfolio.ui.util.swt.SashLayout in project portfolio by buchen.
the class SecuritiesPerformanceView method createBottomTable.
@Override
protected // NOSONAR
void createBottomTable(// NOSONAR
Composite parent) {
Composite sash = new Composite(parent, SWT.NONE);
sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
// folder
CTabFolder folder = new CTabFolder(sash, SWT.BORDER);
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabChart);
Composite chartComposite = new Composite(folder, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(chartComposite);
item.setControl(chartComposite);
chart = new SecuritiesChart(chartComposite, getClient(), new CurrencyConverterImpl(factory, getClient().getBaseCurrency()));
latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabTransactions);
Composite container = new Composite(folder, SWT.NONE);
item.setControl(container);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
folder.setSelection(0);
transactions = new TableViewer(container, SWT.FULL_SELECTION);
ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
SecuritiesPerformanceView.class.getSimpleName() + "@bottom4", // $NON-NLS-1$
getPreferenceStore(), transactions, layout);
// date
Column column = new Column(Messages.ColumnDate, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object e) {
Transaction t = (Transaction) e;
return Values.DateTime.format(t.getDateTime());
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Transaction.class, "dateTime"), SWT.DOWN);
support.addColumn(column);
// transaction type
column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction)
return ((PortfolioTransaction) t).getType().toString();
else if (t instanceof AccountTransaction)
return ((AccountTransaction) t).getType().toString();
else if (t instanceof DividendTransaction)
return AccountTransaction.Type.DIVIDENDS.toString();
else
return Messages.LabelQuote;
}
});
support.addColumn(column);
// shares
column = new Column(Messages.ColumnShares, SWT.None, 80);
column.setLabelProvider(new // NOSONAR
SharesLabelProvider() {
@Override
public // NOSONAR
Long getValue(// NOSONAR
Object t) {
if (t instanceof PortfolioTransaction)
return ((PortfolioTransaction) t).getShares();
else if (t instanceof DividendInitialTransaction)
return ((DividendInitialTransaction) t).getPosition().getShares();
else if (t instanceof DividendFinalTransaction)
return ((DividendFinalTransaction) t).getPosition().getShares();
else if (t instanceof DividendTransaction)
return ((DividendTransaction) t).getShares() != 0L ? ((DividendTransaction) t).getShares() : null;
else
return null;
}
});
support.addColumn(column);
// dividend amount
column = new Column(Messages.ColumnDividendPayment, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnGrossDividend);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Money.format(((DividendTransaction) t).getGrossValue(), getClient().getBaseCurrency());
else
return null;
}
});
support.addColumn(column);
// dividend per share
column = new Column(Messages.ColumnDividendPerShare, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.AmountFraction.formatNonZero(((DividendTransaction) t).getDividendPerShare());
else
return null;
}
});
support.addColumn(column);
// dividend per share
column = new Column(Messages.ColumnPersonalDividendYield, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPersonalDividendYield_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYield());
else
return null;
}
});
support.addColumn(column);
// dividend per share (moving average)
column = new Column(Messages.ColumnPersonalDividendYieldMovingAverage, SWT.RIGHT, 80);
column.setDescription(Messages.ColumnPersonalDividendYieldMovingAverage_Description);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYieldMovingAverage());
else
return null;
}
});
support.addColumn(column);
// einstandskurs / bewertung
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof DividendTransaction)
return null;
else
return Values.Money.format(((Transaction) t).getMonetaryAmount(), getClient().getBaseCurrency());
}
});
support.addColumn(column);
// purchase quote
column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction) {
PortfolioTransaction p = (PortfolioTransaction) t;
return Values.Quote.format(p.getGrossPricePerShare(), getClient().getBaseCurrency());
} else
return null;
}
});
support.addColumn(column);
// gegenkonto
column = new Column(Messages.ColumnAccount, SWT.None, 120);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object t) {
if (t instanceof PortfolioTransaction) {
PortfolioTransaction p = (PortfolioTransaction) t;
return p.getCrossEntry() != null ? p.getCrossEntry().getCrossOwner(p).toString() : null;
} else if (t instanceof DividendTransaction) {
return ((DividendTransaction) t).getAccount().getName();
} else {
return null;
}
}
});
support.addColumn(column);
// note
// $NON-NLS-1$
column = new Column("note", Messages.ColumnNote, SWT.LEFT, 22);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object r) {
return ((Transaction) r).getNote();
}
@Override
public Image getImage(Object r) {
String note = ((Transaction) r).getNote();
return note != null && note.length() > 0 ? Images.NOTE.image() : null;
}
});
// $NON-NLS-1$
column.setSorter(ColumnViewerSorter.create(Transaction.class, "note"));
support.addColumn(column);
support.createColumns();
transactions.getTable().setHeaderVisible(true);
transactions.getTable().setLinesVisible(true);
transactions.setContentProvider(ArrayContentProvider.getInstance());
}
use of name.abuchen.portfolio.ui.util.swt.SashLayout in project portfolio by buchen.
the class AbstractListView method createBody.
@Override
protected final Control createBody(Composite parent) {
Composite sash = new Composite(parent, SWT.NONE);
int style = getSashStyle();
SashLayout sashLayout = new SashLayout(sash, style);
sash.setLayout(sashLayout);
createTopTable(sash);
createBottomTable(sash);
List<Control> children = sashLayout.getChildren();
int childIndex = (style & SWT.BEGINNING) == SWT.BEGINNING ? 0 : 1;
if (children.size() > childIndex) {
Control control = children.get(childIndex);
int size = getPreferenceStore().getInt(identifier);
control.setLayoutData(new SashLayoutData(size != 0 ? size : 250));
sash.addDisposeListener(e -> getPreferenceStore().setValue(identifier, ((SashLayoutData) control.getLayoutData()).getSize()));
}
return sash;
}
use of name.abuchen.portfolio.ui.util.swt.SashLayout in project portfolio by buchen.
the class PortfolioPart method createContainerWithViews.
private void createContainerWithViews(Composite parent) {
container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout());
Composite sash = new Composite(container, SWT.NONE);
SashLayout sashLayout = new SashLayout(sash, SWT.HORIZONTAL | SWT.BEGINNING);
sash.setLayout(sashLayout);
Composite navigationBar = new Composite(sash, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).margins(0, 0).applyTo(navigationBar);
ClientEditorSidebar sidebar = new ClientEditorSidebar(this);
Control control = sidebar.createSidebarControl(navigationBar);
GridDataFactory.fillDefaults().grab(true, true).applyTo(control);
sashLayout.addQuickNavigation(sidebar::menuAboutToShow);
Composite divider = new Composite(navigationBar, SWT.NONE);
divider.setBackground(Colors.SIDEBAR_BORDER);
GridDataFactory.fillDefaults().span(0, 2).hint(1, SWT.DEFAULT).applyTo(divider);
ClientProgressProvider provider = make(ClientProgressProvider.class, client, navigationBar);
GridDataFactory.fillDefaults().grab(true, false).applyTo(provider.getControl());
book = new PageBook(sash, SWT.NONE);
// restore & save size of navigation bar
// $NON-NLS-1$
final String sashIdentifier = PortfolioPart.class.getSimpleName() + "-newsash";
int size = getPreferenceStore().getInt(sashIdentifier);
navigationBar.setLayoutData(new SashLayoutData(size != 0 ? size : 180));
sash.addDisposeListener(e -> getPreferenceStore().setValue(sashIdentifier, ((SashLayoutData) navigationBar.getLayoutData()).getSize()));
sidebar.selectDefaultView();
focus = book;
}
use of name.abuchen.portfolio.ui.util.swt.SashLayout in project portfolio by buchen.
the class SecurityListView method createBottomTable.
// //////////////////////////////////////////////////////////////
// bottom table: folder
// //////////////////////////////////////////////////////////////
@Override
protected void createBottomTable(Composite parent) {
Composite sash = new Composite(parent, SWT.NONE);
sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
// folder
CTabFolder folder = new CTabFolder(sash, SWT.BORDER);
// latest
latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
// tab 1: chart
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabChart);
Composite chartComposite = new Composite(folder, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(chartComposite);
item.setControl(chartComposite);
chart = new SecuritiesChart(chartComposite, getClient(), new CurrencyConverterImpl(factory, getClient().getBaseCurrency()));
// tab 2: historical quotes
item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabHistoricalQuotes);
item.setControl(createPricesTable(folder));
// tab 3: transactions
item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabTransactions);
item.setControl(createTransactionTable(folder));
// tab 4: event
item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.SecurityTabEvents);
item.setControl(createEventsTable(folder));
folder.setSelection(0);
}
use of name.abuchen.portfolio.ui.util.swt.SashLayout in project portfolio by buchen.
the class TreeMapViewer method createControl.
@Override
public Control createControl(Composite parent) {
Composite sash = new Composite(parent, SWT.NONE);
sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
Composite container = new Composite(sash, SWT.NONE);
container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
treeMap = new TreeMap<>(container);
treeMap.setTreeMapLayout(new SquarifiedLayout<TaxonomyNode>(10));
treeMap.setLabelProvider((model, rectangle) -> rectangle.getNode().getName());
legend = new TreeMapLegend(container, treeMap, getModel(), getRenderer());
final SecurityDetailsViewer details = new SecurityDetailsViewer(sash, SWT.NONE, getModel().getClient(), true);
treeMap.addSelectionChangeListener((model, rectangle, label) -> {
TaxonomyNode node = rectangle.getNode();
details.setInput(node.getBackingSecurity());
});
// layout tree map + legend
GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).applyTo(container);
GridDataFactory.fillDefaults().grab(true, true).applyTo(treeMap);
GridDataFactory.fillDefaults().grab(true, false).applyTo(legend);
// layout sash
details.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(details.getControl())));
treeMap.setRectangleRenderer(new ClassificationRectangleRenderer(getModel(), getRenderer()));
treeMap.setTreeModel(new Model(getModel()));
legend.setRootItem(getModel().getChartRenderingRootNode());
return sash;
}
Aggregations