TableViewerColumn viewColName = new TableViewerColumn(calendarViewer, SWT.NONE);
viewColName.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ITradingCalendar calendar = (ITradingCalendar) element;
return calendar.getName();
}
});
TableColumn columnName = viewColName.getColumn();
columnName.setText("Name");
columnName.setWidth(150);
columnName.setResizable(true);
TableViewerColumn viewColDesc = new TableViewerColumn(calendarViewer, SWT.NONE);
viewColDesc.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ITradingCalendar calendar = (ITradingCalendar) element;
return calendar.getDescription();
}
});
TableColumn columnDesc = viewColDesc.getColumn();
columnDesc.setText("Description");
columnDesc.setWidth(200);
columnDesc.setResizable(true);
Table table = calendarViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
calendarViewer.setContentProvider(new ArrayContentProvider());
calendarViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
Object firstElement = selection.getFirstElement();
if (firstElement != null && firstElement instanceof ITradingCalendar) {
tradingCalendar = (ITradingCalendar) firstElement;
}
}
}});
calendarViewer.setInput(tradingCalendars);
String currentCaledarName = chartModel.getTradingCalendar().getName();
for (int i = 0; i < tradingCalendars.size(); i++) {
ITradingCalendar calendar = tradingCalendars.get(i);
if (calendar != null && calendar.getName().equals(currentCaledarName)) {
table.setSelection(i);
break;
}
}
return tabFolder;