Search in sources :

Example 1 with ArchiveServerURL

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);
}
Also used : MinSizeTableColumnLayout(org.csstudio.ui.util.MinSizeTableColumnLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ArchiveServerURL(org.csstudio.trends.databrowser3.preferences.ArchiveServerURL) Label(org.eclipse.swt.widgets.Label) ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) Combo(org.eclipse.swt.widgets.Combo) ViewerCell(org.eclipse.jface.viewers.ViewerCell) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MinSizeTableColumnLayout(org.csstudio.ui.util.MinSizeTableColumnLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableColumnSortHelper(org.csstudio.apputil.ui.swt.TableColumnSortHelper) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Aggregations

TableColumnSortHelper (org.csstudio.apputil.ui.swt.TableColumnSortHelper)1 ArchiveDataSource (org.csstudio.trends.databrowser3.model.ArchiveDataSource)1 ArchiveServerURL (org.csstudio.trends.databrowser3.preferences.ArchiveServerURL)1 MinSizeTableColumnLayout (org.csstudio.ui.util.MinSizeTableColumnLayout)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 ViewerCell (org.eclipse.jface.viewers.ViewerCell)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Table (org.eclipse.swt.widgets.Table)1