}
private void createCalculationItem(CTabFolder folder, String title)
{
Composite container = new Composite(folder, SWT.NONE);
TreeColumnLayout layout = new TreeColumnLayout();
container.setLayout(layout);
calculation = new TreeViewer(container, SWT.FULL_SELECTION);
final Font boldFont = JFaceResources.getFontRegistry().getBold(container.getFont().getFontData()[0].getName());
TreeViewerColumn column = new TreeViewerColumn(calculation, SWT.NONE);
column.getColumn().setText(Messages.ColumnLable);
column.setLabelProvider(new ColumnLabelProvider()
{
@Override
public String getText(Object element)
{
if (element instanceof ClientPerformanceSnapshot.Category)
{
ClientPerformanceSnapshot.Category cat = (ClientPerformanceSnapshot.Category) element;
return cat.getLabel();
}
else if (element instanceof ClientPerformanceSnapshot.Position)
{
ClientPerformanceSnapshot.Position pos = (ClientPerformanceSnapshot.Position) element;
return pos.getLabel();
}
return null;
}
@Override
public Image getImage(Object element)
{
if (element instanceof ClientPerformanceSnapshot.Category)
{
return PortfolioPlugin.image(PortfolioPlugin.IMG_CATEGORY);
}
else if (element instanceof ClientPerformanceSnapshot.Position)
{
ClientPerformanceSnapshot.Position position = (ClientPerformanceSnapshot.Position) element;
return position.getSecurity() != null ? PortfolioPlugin.image(PortfolioPlugin.IMG_SECURITY) : null;
}
return null;
}
@Override
public Font getFont(Object element)
{
if (element instanceof ClientPerformanceSnapshot.Category)
return boldFont;
return null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(350));
column = new TreeViewerColumn(calculation, SWT.RIGHT);
column.getColumn().setText(Messages.ColumnValue);
column.setLabelProvider(new ColumnLabelProvider()
{
@Override
public String getText(Object element)
{
if (element instanceof ClientPerformanceSnapshot.Category)
{
ClientPerformanceSnapshot.Category cat = (ClientPerformanceSnapshot.Category) element;
return Values.Amount.format(cat.getValuation());
}
else if (element instanceof ClientPerformanceSnapshot.Position)
{
ClientPerformanceSnapshot.Position pos = (ClientPerformanceSnapshot.Position) element;
return Values.Amount.format(pos.getValuation());
}
return null;
}
@Override
public Font getFont(Object element)
{
if (element instanceof ClientPerformanceSnapshot.Category)
return boldFont;
return null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(80));
calculation.getTree().setHeaderVisible(true);
calculation.getTree().setLinesVisible(true);
calculation.setContentProvider(new PerformanceContentProvider());