use of org.csstudio.trends.databrowser3.preferences.ArchiveServerURL in project org.csstudio.display.builder by kasemir.
the class ArchiveListGUI method createGUI.
/**
* Create GUI elements
* @param parent Parent widget
*/
private void createGUI(final Composite parent) {
final GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// URL: ___urls___ [info]
Label l;
l = new Label(parent, 0);
l.setText(Messages.Search_URL);
l.setLayoutData(new GridData());
urls = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
urls.setToolTipText(Messages.Search_URL_TT);
for (ArchiveServerURL url : server_urls) urls.add(url.getDisplayName());
urls.setLayoutData(new GridData(SWT.FILL, 0, true, false));
if (urls.getItemCount() <= 0) {
urls.add(Messages.ArchiveListGUI_NoArchives);
urls.setEnabled(false);
}
urls.select(0);
info = new Button(parent, SWT.PUSH);
info.setText(Messages.ArchiveServerInfo);
info.setToolTipText(Messages.ArchiveServerInfoTT);
info.setEnabled(false);
// Table for archives, displaying array of ArchiveDataSource entries
// TableColumnLayout requires table in its own container
final Composite table_parent = new Composite(parent, 0);
table_parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
table_parent.setLayout(table_layout);
archive_table = new TableViewer(table_parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
archive_table.setContentProvider(new ArrayContentProvider());
TableViewerColumn col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveName, 150, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getName());
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getName().compareTo(item2.getName());
}
};
col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveDescription, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getDescription());
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getDescription().compareTo(item2.getDescription());
}
};
col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveKey, 35, 5);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(Integer.toString(archive.getKey()));
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getKey() - item2.getKey();
}
};
final Table table = archive_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
}
Aggregations