use of org.eclipse.jface.layout.TableColumnLayout 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.layout.TableColumnLayout in project portfolio by buchen.
the class DividendsMatrixTab method createControl.
@Override
public Control createControl(Composite parent) {
LocalResourceManager resources = new LocalResourceManager(JFaceResources.getResources(), parent);
boldFont = resources.createFont(FontDescriptor.createFrom(parent.getFont()).setStyle(SWT.BOLD));
Composite container = new Composite(parent, SWT.NONE);
tableLayout = new TableColumnLayout();
container.setLayout(tableLayout);
tableViewer = new TableViewer(container, SWT.FULL_SELECTION);
ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
createColumns(tableViewer, tableLayout);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.addSelectionChangedListener(event -> {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) ((IStructuredSelection) event.getSelection()).getFirstElement()).getVehicle();
if (vehicle != null && vehicle instanceof Security)
selectionService.setSelection(new SecuritySelection(model.getClient(), (Security) vehicle));
});
tableViewer.setInput(model.getAllLines());
for (TableColumn c : tableViewer.getTable().getColumns()) c.pack();
model.addUpdateListener(() -> updateColumns(tableViewer, tableLayout));
return container;
}
use of org.eclipse.jface.layout.TableColumnLayout 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.layout.TableColumnLayout in project portfolio by buchen.
the class AddTaxonomyPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
setControl(container);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
final TableViewer viewer = new TableViewer(container);
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(90));
column.getColumn().setText(Messages.ColumnTaxonomy);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((TaxonomyTemplate) element).getName();
}
});
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(10));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return null;
}
@Override
public Image getImage(Object element) {
TaxonomyTemplate t = (TaxonomyTemplate) element;
if (taxonomiesAdded.contains(t.getId()))
return Images.CHECK.image();
else
return null;
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
TaxonomyTemplate template = (TaxonomyTemplate) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (template != null && !taxonomiesAdded.contains(template.getId())) {
taxonomiesAdded.add(template.getId());
client.addTaxonomy(template.build());
viewer.refresh(template);
}
}
});
viewer.getTable().setHeaderVisible(true);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setInput(TaxonomyTemplate.list());
setPageComplete(true);
}
use of org.eclipse.jface.layout.TableColumnLayout in project portfolio by buchen.
the class ImportIndizesPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
GridLayoutFactory.fillDefaults().applyTo(container);
comboDropDown = new Combo(container, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.FILL).applyTo(comboDropDown);
final ComboViewer comboViewer = new ComboViewer(comboDropDown);
comboViewer.setContentProvider(ArrayContentProvider.getInstance());
comboViewer.setInput(proposals);
Composite tableContainer = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(tableContainer);
TableColumnLayout layout = new TableColumnLayout();
tableContainer.setLayout(layout);
final TableViewer tViewer = new TableViewer(tableContainer);
comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ProposedSecurities element = (ProposedSecurities) ((IStructuredSelection) event.getSelectionProvider().getSelection()).getFirstElement();
if (element != null)
tViewer.setInput(element.securities);
}
});
Table table = tViewer.getTable();
table.setHeaderVisible(true);
tViewer.setContentProvider(ArrayContentProvider.getInstance());
TableViewerColumn aCol = new TableViewerColumn(tViewer, SWT.NONE);
layout.setColumnData(aCol.getColumn(), new ColumnWeightData(90));
aCol.getColumn().setText(Messages.ColumnSecurity);
aCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Security) element).getName();
}
@Override
public Image getImage(Object element) {
return Images.SECURITY.image();
}
});
aCol = new TableViewerColumn(tViewer, SWT.NONE);
layout.setColumnData(aCol.getColumn(), new ColumnWeightData(10));
aCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return null;
}
@Override
public Image getImage(Object element) {
return client.getSecurities().contains(element) ? Images.CHECK.image() : null;
}
});
tViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
Security security = (Security) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (security != null && !client.getSecurities().contains(security)) {
client.addSecurity(security);
tViewer.refresh(security);
}
}
});
Button button = new Button(container, SWT.PUSH);
button.setText(Messages.NewFileWizardAddAll);
GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.FILL).applyTo(button);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ProposedSecurities proposal = (ProposedSecurities) ((IStructuredSelection) comboViewer.getSelection()).getFirstElement();
for (Security security : proposal.securities) {
if (!client.getSecurities().contains(security))
client.addSecurity(security);
}
tViewer.refresh();
}
});
comboDropDown.select(0);
container.pack();
setPageComplete(true);
}
Aggregations