use of name.abuchen.portfolio.ui.util.viewers.MonthEditingSupport in project portfolio by buchen.
the class ConsumerPriceIndexListView method createTopTable.
@Override
protected void createTopTable(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
indices = new TableViewer(container, SWT.FULL_SELECTION);
ColumnEditingSupport.prepare(indices);
ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
ConsumerPriceIndexListView.class.getSimpleName() + "@bottom", // $NON-NLS-1$
getPreferenceStore(), // $NON-NLS-1$
indices, layout);
Column column = new Column(Messages.ColumnYear, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return String.valueOf(((ConsumerPriceIndex) element).getYear());
}
});
// $NON-NLS-1$ //$NON-NLS-2$
ColumnViewerSorter.create(ConsumerPriceIndex.class, "year", "month").attachTo(column, SWT.DOWN);
// $NON-NLS-1$
new ValueEditingSupport(ConsumerPriceIndex.class, "year", Values.Year).addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnMonth, SWT.None, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
int month = ((ConsumerPriceIndex) element).getMonth();
return Month.of(month).getDisplayName(TextStyle.FULL, Locale.getDefault());
}
});
// $NON-NLS-1$ //$NON-NLS-2$
ColumnViewerSorter.create(ConsumerPriceIndex.class, "month", "year").attachTo(column);
// $NON-NLS-1$
new MonthEditingSupport(ConsumerPriceIndex.class, "month").addListener(this).attachTo(column);
support.addColumn(column);
column = new Column(Messages.ColumnIndex, SWT.RIGHT, 80);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return Values.Index.format(((ConsumerPriceIndex) element).getIndex());
}
});
// $NON-NLS-1$
ColumnViewerSorter.create(ConsumerPriceIndex.class, "index").attachTo(column);
// $NON-NLS-1$
new ValueEditingSupport(ConsumerPriceIndex.class, "index", Values.Index).addListener(this).attachTo(column);
support.addColumn(column);
support.createColumns();
indices.getTable().setHeaderVisible(true);
indices.getTable().setLinesVisible(true);
indices.setContentProvider(ArrayContentProvider.getInstance());
indices.setInput(getClient().getConsumerPriceIndices());
indices.refresh();
hookContextMenu(indices.getTable(), new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
});
}
Aggregations