Search in sources :

Example 16 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell in project tdq-studio-se by Talend.

the class GridTableViewer method editElement.

/**
 * {@inheritDoc}
 */
public void editElement(Object element, int column) {
    try {
        getControl().setRedraw(false);
        Widget item = findItem(element);
        if (item != null) {
            ViewerRow row = getViewerRowFromItem(item);
            if (row != null) {
                ViewerCell cell = row.getCell(column);
                if (cell != null) {
                    triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
                }
            }
        }
    } finally {
        getControl().setRedraw(true);
    }
// }
}
Also used : Widget(org.eclipse.swt.widgets.Widget) ViewerRow(org.eclipse.jface.viewers.ViewerRow) ColumnViewerEditorActivationEvent(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent) ViewerCell(org.eclipse.jface.viewers.ViewerCell)

Example 17 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell in project tdq-studio-se by Talend.

the class GridTableViewer method updateRowHeader.

private void updateRowHeader(Widget widget) {
    if (rowHeaderLabelProvider != null) {
        ViewerCell cell = getViewerRowFromItem(widget).getCell(Integer.MAX_VALUE);
        rowHeaderLabelProvider.update(cell);
    }
}
Also used : ViewerCell(org.eclipse.jface.viewers.ViewerCell)

Example 18 with ViewerCell

use of org.eclipse.jface.viewers.ViewerCell in project jbosstools-openshift by jbosstools.

the class TemplateParametersPage method buildTableViewer.

private TableViewer buildTableViewer(Table table, Composite tableContainer, ObservableMap<String, IStatus> cellsValidationStatusObservable, TableViewerCellDecorationManager decorations) {
    final TableViewerBuilder builder = new TableViewerBuilder(table, tableContainer);
    TableViewer tableViewer = builder.contentProvider(new ObservableListContentProvider()).column(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            Assert.isLegal(cell.getElement() instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
            IParameter parameter = (IParameter) cell.getElement();
            String label = parameter.getName();
            if (parameter.isRequired()) {
                label = markRequired(label);
            }
            cell.setText(label);
        }

        private String markRequired(String label) {
            return label += " *";
        }

        @Override
        public String getToolTipText(Object object) {
            Assert.isLegal(object instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
            return ((IParameter) object).getDescription();
        }

        @Override
        public int getToolTipDisplayDelayTime(Object object) {
            return 0;
        }
    }).name("Name").align(SWT.LEFT).weight(1).minWidth(180).buildColumn().column(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            Assert.isLegal(cell.getElement() instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
            final IParameter parameter = (IParameter) cell.getElement();
            String label = TemplateParameterViewerUtils.getValueLabel(parameter);
            cell.setText(label);
            boolean italic = ((ApplicationSourceFromTemplateModel) model).isParameterModified(parameter);
            builder.applyFont(cell, italic);
            IStatus validationStatus = validate(parameter);
            cellsValidationStatusObservable.put(parameter.getName(), validationStatus);
            decorations.toggle(!validationStatus.isOK(), cell);
        }

        private IStatus validate(IParameter parameter) {
            if (parameter.isRequired() && StringUtils.isEmpty(parameter.getValue()) && StringUtils.isEmpty(parameter.getGeneratorName())) {
                return ValidationStatus.error(NLS.bind("Parameter {0} is required, please provide a value.", parameter.getName()));
            }
            IStatus status = gitSourceValidator.validate(parameter);
            if (!status.isOK()) {
                return status;
            }
            return ValidationStatus.ok();
        }

        @Override
        public String getToolTipText(Object object) {
            Assert.isLegal(object instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
            return ((IParameter) object).getDescription();
        }

        @Override
        public int getToolTipDisplayDelayTime(Object object) {
            return 0;
        }
    }).name("Value").align(SWT.LEFT).weight(1).buildColumn().buildViewer();
    tableViewer.setComparator(new TemplateParameterViewerUtils.ParameterNameViewerComparator());
    return tableViewer;
}
Also used : ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) IParameter(com.openshift.restclient.model.template.IParameter) IStatus(org.eclipse.core.runtime.IStatus) ViewerCell(org.eclipse.jface.viewers.ViewerCell) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Example 19 with ViewerCell

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

the class TableValueViewer method showHistory.

/**
 * Show history
 */
private void showHistory() {
    if (currentData == null)
        return;
    ViewerCell[] cells = cellSelectionManager.getSelectedCells();
    if (cells.length == 0)
        return;
    for (int i = 0; i < cells.length; i++) {
        TableColumnDefinition column = currentData.getColumnDefinition(cells[i].getColumnIndex());
        final String instance = buildInstanceString(cells[i].getViewerRow());
        String id = // $NON-NLS-1$ //$NON-NLS-2$
        Long.toString(objectId) + "&" + Long.toString(dciId) + "@" + safeEncode(column.getDisplayName() + ": " + instance.replace("~~~", " / ")) + // $NON-NLS-1$
        "@" + safeEncode(instance) + "@" + // $NON-NLS-1$ //$NON-NLS-2$
        safeEncode(column.getName());
        final IWorkbenchPage page = (viewPart != null) ? viewPart.getSite().getPage() : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        try {
            page.showView(HistoricalDataView.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 20 with ViewerCell

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

the class CellSelectionManager method setFocusCell.

/**
 * @param focusCell
 */
void setFocusCell(ViewerCell focusCell, boolean clearSelection) {
    if (clearSelection) {
        for (ViewerCell cell : selectedCells) cellHighlighter.unmarkCell(cell);
        selectedCells.clear();
        if (focusCell != null) {
            selectedCells.add(focusCell);
            cellHighlighter.markCell(focusCell);
        }
    } else if (focusCell != null) {
        if (selectedCells.contains(focusCell)) {
            selectedCells.remove(focusCell);
            cellHighlighter.unmarkCell(focusCell);
        } else {
            selectedCells.add(focusCell);
            cellHighlighter.markCell(focusCell);
        }
    }
    ViewerCell oldCell = this.focusCell;
    if (this.focusCell != null && !this.focusCell.getItem().isDisposed()) {
        this.focusCell.getItem().removeDisposeListener(itemDeletionListener);
    }
    this.focusCell = focusCell;
    if (this.focusCell != null && !this.focusCell.getItem().isDisposed()) {
        this.focusCell.getItem().addDisposeListener(itemDeletionListener);
    }
    if (focusCell != null) {
        focusCell.scrollIntoView();
    }
    cellHighlighter.focusCellChanged(focusCell, oldCell);
    viewer.getControl().getAccessible().setFocus(ACC.CHILDID_SELF);
}
Also used : 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