use of org.eclipse.jface.viewers.ColumnPixelData in project portfolio by buchen.
the class DividendsMatrixTab method createMonthColumn.
private void createMonthColumn(TableViewer records, TableColumnLayout layout, LocalDate start, int index) {
TableViewerColumn column = new TableViewerColumn(records, SWT.RIGHT);
column.getColumn().setText(formatter.format(start));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Line line = (DividendsViewModel.Line) element;
return line.getVehicle() != null ? Values.Amount.formatNonZero(line.getValue(index)) : Values.Amount.format(line.getValue(index));
}
@Override
public String getToolTipText(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return TextUtil.tooltip(vehicle != null ? vehicle.getName() : null);
}
@Override
public Font getFont(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return vehicle != null ? null : boldFont;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(50));
}
use of org.eclipse.jface.viewers.ColumnPixelData in project portfolio by buchen.
the class DividendsMatrixTab method createSecurityColumn.
protected void createSecurityColumn(TableViewer records, TableColumnLayout layout, boolean isSorted) {
TableViewerColumn column = new TableViewerColumn(records, SWT.NONE);
column.getColumn().setText(Messages.ColumnSecurity);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return vehicle != null ? Images.SECURITY.image() : null;
}
@Override
public String getText(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return vehicle != null ? vehicle.getName() : Messages.ColumnSum;
}
@Override
public Font getFont(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return vehicle != null ? null : boldFont;
}
});
ColumnViewerSorter.create((o1, o2) -> {
int direction = ColumnViewerSorter.SortingContext.getSortDirection();
DividendsViewModel.Line line1 = (DividendsViewModel.Line) o1;
DividendsViewModel.Line line2 = (DividendsViewModel.Line) o2;
if (line1.getVehicle() == null)
return direction == SWT.DOWN ? 1 : -1;
if (line2.getVehicle() == null)
return direction == SWT.DOWN ? -1 : 1;
String n1 = line1.getVehicle().getName();
String n2 = line2.getVehicle().getName();
return n1.compareToIgnoreCase(n2);
}).attachTo(records, column, isSorted);
layout.setColumnData(column.getColumn(), new ColumnPixelData(200));
}
use of org.eclipse.jface.viewers.ColumnPixelData in project portfolio by buchen.
the class DividendsMatrixTab method createSumColumn.
protected void createSumColumn(TableViewer records, TableColumnLayout layout) {
TableViewerColumn column;
column = new TableViewerColumn(records, SWT.RIGHT);
column.getColumn().setText(Messages.ColumnSum);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
DividendsViewModel.Line line = (DividendsViewModel.Line) element;
if (showOnlyOneYear) {
int noOfMonths = Math.min(12, line.getNoOfMonths());
long sum = 0;
for (int ii = 0; ii < noOfMonths; ii++) sum += line.getValue(ii);
return Values.Amount.formatNonZero(sum);
} else {
return Values.Amount.formatNonZero(line.getSum());
}
}
@Override
public Font getFont(Object element) {
return boldFont;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(200));
}
use of org.eclipse.jface.viewers.ColumnPixelData in project portfolio by buchen.
the class PreviewQuotesPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
setControl(container);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
Button checkbox = new Button(container, SWT.CHECK);
checkbox.setText(Messages.SplitWizardLabelUpdateQuotes);
Composite tableContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tableContainer);
TableColumnLayout layout = new TableColumnLayout();
tableContainer.setLayout(layout);
tableViewer = new TableViewer(tableContainer, SWT.BORDER);
Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn column = new TableColumn(tableViewer.getTable(), SWT.None);
column.setText(Messages.ColumnDate);
layout.setColumnData(column, new ColumnPixelData(80, true));
column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
column.setText(Messages.ColumnCurrentQuote);
layout.setColumnData(column, new ColumnPixelData(80, true));
column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
column.setText(Messages.ColumnUpdatedQuote);
layout.setColumnData(column, new ColumnPixelData(80, true));
tableViewer.setLabelProvider(new TransactionLabelProvider());
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
// bindings
DataBindingContext context = new DataBindingContext();
//
context.bindValue(//
WidgetProperties.selection().observe(checkbox), // $NON-NLS-1$
BeanProperties.value("changeHistoricalQuotes").observe(model));
checkbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tableViewer.refresh();
}
});
}
use of org.eclipse.jface.viewers.ColumnPixelData in project portfolio by buchen.
the class PreviewTransactionsPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
setControl(container);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
Button checkbox = new Button(container, SWT.CHECK);
checkbox.setText(Messages.SplitWizardLabelUpdateTransactions);
Composite tableContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tableContainer);
TableColumnLayout layout = new TableColumnLayout();
tableContainer.setLayout(layout);
tableViewer = new TableViewer(tableContainer, SWT.BORDER);
Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn column = new TableColumn(tableViewer.getTable(), SWT.None);
column.setText(Messages.ColumnDate);
layout.setColumnData(column, new ColumnPixelData(100, true));
column = new TableColumn(tableViewer.getTable(), SWT.None);
column.setText(Messages.ColumnTransactionType);
layout.setColumnData(column, new ColumnPixelData(80, true));
column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
column.setText(Messages.ColumnCurrentShares);
layout.setColumnData(column, new ColumnPixelData(80, true));
column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
column.setText(Messages.ColumnUpdatedShares);
layout.setColumnData(column, new ColumnPixelData(80, true));
column = new TableColumn(tableViewer.getTable(), SWT.None);
column.setText(Messages.ColumnSource);
layout.setColumnData(column, new ColumnPixelData(200, true));
tableViewer.setLabelProvider(new TransactionLabelProvider());
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
// bindings
DataBindingContext context = new DataBindingContext();
//
context.bindValue(//
WidgetProperties.selection().observe(checkbox), // $NON-NLS-1$
BeanProperties.value("changeTransactions").observe(model));
checkbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tableViewer.refresh();
}
});
}
Aggregations