Search in sources :

Example 41 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell 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)

Example 42 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell in project org.csstudio.display.builder by kasemir.

the class ArchivesTableHandler method createColumns.

/**
 * Create table columns: Auto-sizable, with label provider and editor
 *  @param table_layout
 *  @param operations_manager
 *  @param archives_table
 */
public void createColumns(TableColumnLayout table_layout, final UndoableActionManager operations_manager, final TableViewer archives_table) {
    table_viewer = archives_table;
    TableViewerColumn col;
    // Archive Name Column ----------
    col = TableHelper.createColumn(table_layout, archives_table, Messages.ArchiveName, 100, 20);
    col.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(final ViewerCell cell) {
            final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
            cell.setText(archive.getName());
        }
    });
    // Archive Key Column ----------
    col = TableHelper.createColumn(table_layout, archives_table, Messages.ArchiveKey, 20, 5);
    col.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(final ViewerCell cell) {
            final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
            cell.setText(Integer.toString(archive.getKey()));
        }
    });
    // Archive Server URL Column ----------
    col = TableHelper.createColumn(table_layout, archives_table, Messages.URL, 50, 100);
    col.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(final ViewerCell cell) {
            final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
            cell.setText(archive.getUrl());
        }
    });
}
Also used : ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) ViewerCell(org.eclipse.jface.viewers.ViewerCell) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Example 43 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell in project netxms by netxms.

the class TableValueViewer method showDataComparisonChart.

/**
 * Show line chart
 */
private void showDataComparisonChart(int chartType) {
    if (currentData == null)
        return;
    ViewerCell[] cells = cellSelectionManager.getSelectedCells();
    if (cells.length == 0)
        return;
    // $NON-NLS-1$
    String id = Long.toString(uniqueId++) + "&" + Integer.toString(chartType);
    for (int i = 0; i < cells.length; i++) {
        TableColumnDefinition column = currentData.getColumnDefinition(cells[i].getColumnIndex());
        String instance = buildInstanceString(cells[i].getViewerRow());
        int source = currentData.getSource();
        id += // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        "&" + Long.toString(objectId) + "@" + Long.toString(dciId) + "@" + Integer.toString(source) + "@" + Integer.toString(column.getDataType().getValue()) + "@" + safeEncode(currentData.getTitle()) + // $NON-NLS-1$ //$NON-NLS-2$
        "@" + safeEncode(column.getDisplayName() + ": " + instance.replace("~~~", " / ")) + "@" + safeEncode(instance) + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
        "@" + safeEncode(column.getName());
    }
    final IWorkbenchPage page = (viewPart != null) ? viewPart.getSite().getPage() : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
        page.showView(DataComparisonView.ID, id, IWorkbenchPage.VIEW_ACTIVATE);
    } catch (Exception e) {
        MessageDialogHelper.openError(page.getWorkbenchWindow().getShell(), Messages.get().TableValue_Error, String.format(Messages.get().TableValue_ErrorOpeningView, e.getLocalizedMessage()));
    }
}
Also used : TableColumnDefinition(org.netxms.client.TableColumnDefinition) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ViewerCell(org.eclipse.jface.viewers.ViewerCell) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 44 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell in project netxms by netxms.

the class TableValueViewer method showLineChart.

/**
 * Show line chart
 */
private void showLineChart() {
    if (currentData == null)
        return;
    ViewerCell[] cells = cellSelectionManager.getSelectedCells();
    if (cells.length == 0)
        return;
    StringBuilder sb = new StringBuilder();
    sb.append(uniqueId++);
    for (int i = 0; i < cells.length; i++) {
        TableColumnDefinition column = currentData.getColumnDefinition(cells[i].getColumnIndex());
        final String instance = buildInstanceString(cells[i].getViewerRow());
        sb.append("&");
        sb.append(ChartDciConfig.TABLE);
        sb.append("@");
        sb.append(objectId);
        sb.append("@");
        sb.append(dciId);
        sb.append("@");
        sb.append(safeEncode(column.getDisplayName() + ": " + instance.replace("~~~", " / ")));
        sb.append("@");
        sb.append(safeEncode(instance));
        sb.append("@");
        sb.append(safeEncode(column.getName()));
    }
    final IWorkbenchPage page = (viewPart != null) ? viewPart.getSite().getPage() : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
        page.showView(HistoricalGraphView.ID, sb.toString(), IWorkbenchPage.VIEW_ACTIVATE);
    } catch (Exception e) {
        MessageDialogHelper.openError(page.getWorkbenchWindow().getShell(), Messages.get().TableValue_Error, String.format(Messages.get().TableValue_ErrorOpeningView, e.getLocalizedMessage()));
    }
}
Also used : TableColumnDefinition(org.netxms.client.TableColumnDefinition) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ViewerCell(org.eclipse.jface.viewers.ViewerCell) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 45 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell in project netxms by netxms.

the class GalleryTreeViewer method editElement.

public void editElement(Object element, int column) {
    if (element instanceof TreePath) {
        setSelection(new TreeSelection((TreePath) element));
        GalleryItem[] items = gallery.getSelection();
        if (items.length == 1) {
            ViewerRow row = getViewerRowFromItem(items[0]);
            if (row != null) {
                ViewerCell cell = row.getCell(column);
                if (cell != null) {
                    getControl().setRedraw(false);
                    triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
                    getControl().setRedraw(true);
                }
            }
        }
    } else {
        super.editElement(element, column);
    }
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ViewerRow(org.eclipse.jface.viewers.ViewerRow) ColumnViewerEditorActivationEvent(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent) GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem) ViewerCell(org.eclipse.jface.viewers.ViewerCell)

Aggregations

ViewerCell (org.eclipse.jface.viewers.ViewerCell)54 TableViewer (org.eclipse.jface.viewers.TableViewer)21 Composite (org.eclipse.swt.widgets.Composite)21 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)18 GridData (org.eclipse.swt.layout.GridData)18 Table (org.eclipse.swt.widgets.Table)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Button (org.eclipse.swt.widgets.Button)12 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)11 StyledCellLabelProvider (org.eclipse.jface.viewers.StyledCellLabelProvider)11 Label (org.eclipse.swt.widgets.Label)11 StyledString (org.eclipse.jface.viewers.StyledString)10 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Point (org.eclipse.swt.graphics.Point)9 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)8 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)8