Example usage for org.eclipse.jface.viewers ViewerCell setText

List of usage examples for org.eclipse.jface.viewers ViewerCell setText

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ViewerCell setText.

Prototype

public void setText(String text) 

Source Link

Document

Set the text for the cell.

Usage

From source file:net.ssehub.easy.producer.ui.productline_editor.configuration.AbstractConfigurationLabelProvider.java

@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    int index = cell.getVisualIndex();
    String text = getColumnText(element, index);
    cell.setText(text);
    cell.setImage(getColumnImage(element, index));
    if (ColumnType.ERROR == columType(index) && null != text) {
        cell.setForeground(ERROR_COLOR);
    } else {/* w w w . ja v  a 2 s.  c o m*/
        cell.setForeground(getForeground(element));
    }
    cell.setBackground(getBackground(element));
}

From source file:net.tourbook.common.util.ColumnDefinition.java

License:Open Source License

/**
 * Print double value with the detail value formatter.
 * /*w w w.  j a va  2s  . c om*/
 * @param cell
 * @param value
 */
public void printDetailValue(final ViewerCell cell, final double value) {

    if (value == 0) {

        cell.setText(UI.EMPTY_STRING);

    } else {

        cell.setText(getValueFormatter_Detail().printDouble(value));
    }
}

From source file:net.tourbook.common.util.ColumnDefinition.java

License:Open Source License

/**
 * Print long value with the detail value formatter.
 * /*from w w  w .j  a va 2  s .com*/
 * @param cell
 * @param value
 * @param isDetail
 */
public void printDetailValue(final ViewerCell cell, final long value) {

    if (value == 0) {

        cell.setText(UI.EMPTY_STRING);

    } else {

        cell.setText(getValueFormatter_Detail().printLong(value));
    }
}

From source file:net.tourbook.common.util.ColumnDefinition.java

License:Open Source License

/**
 * Print double value with a value formatter.
 * /*from ww  w. j a  v  a  2s .  com*/
 * @param cell
 * @param value
 * @param isDetail
 */
public void printDoubleValue(final ViewerCell cell, final double value, final boolean isDetail) {

    if (value == 0) {

        cell.setText(UI.EMPTY_STRING);

    } else if (isDetail) {

        cell.setText(getValueFormatter_Detail().printDouble(value));

    } else {

        cell.setText(getValueFormatter().printDouble(value));
    }
}

From source file:net.tourbook.common.util.ColumnDefinition.java

License:Open Source License

/**
 * Print long value with a value formatter.
 * //  w ww  .ja  v a 2  s  .co  m
 * @param cell
 * @param value
 * @param isDetail
 */
public void printLongValue(final ViewerCell cell, final long value, final boolean isDetail) {

    if (value == 0) {

        cell.setText(UI.EMPTY_STRING);

    } else if (isDetail) {

        cell.setText(getValueFormatter_Detail().printLong(value));

    } else {

        cell.setText(getValueFormatter().printLong(value));
    }
}

From source file:net.tourbook.common.util.ColumnDefinition.java

License:Open Source License

/**
 * Print double value without fraction digits.
 * /*from w w  w.ja v  a 2s  .c o  m*/
 * @param cell
 * @param value
 */
public void printValue_0(final ViewerCell cell, final double value) {

    if (value == 0) {
        cell.setText(UI.EMPTY_STRING);
    } else {
        cell.setText(_nf0.format(value));
    }
}

From source file:net.tourbook.common.util.DialogModifyColumns.java

License:Open Source License

private void createUI_12_ProfileViewer(final Composite parent) {

    final Composite layoutContainer = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults()//
            .grab(true, false).hint(SWT.DEFAULT, _pc.convertHeightInCharsToPixels(7)).applyTo(layoutContainer);

    final TableColumnLayout tableLayout = new TableColumnLayout();
    layoutContainer.setLayout(tableLayout);

    final Table table = new Table(layoutContainer, //
            SWT.SINGLE//from w w  w  . j a  va2  s.c  om
                    //                  | SWT.H_SCROLL
                    //                  | SWT.V_SCROLL
                    | SWT.BORDER | SWT.FULL_SELECTION);

    table.setHeaderVisible(false);
    table.setLinesVisible(false);

    _profileViewer = new CheckboxTableViewer(table);

    _profileViewer.setUseHashlookup(true);
    _profileViewer.setComparator(_profileComparator);

    _profileViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(final Object inputElement) {
            return _dialog_Profiles.toArray();
        }

        @Override
        public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
        }
    });

    _profileViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            onProfileViewer_Select(event);
        }
    });

    _profileViewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(final DoubleClickEvent event) {
            onProfile_Rename();
        }
    });

    /*
     * Create single column
     */
    TableViewerColumn tvc;

    // column: name
    tvc = new TableViewerColumn(_profileViewer, SWT.NONE);
    tvc.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final ColumnProfile profile = ((ColumnProfile) cell.getElement());

            cell.setText(profile.name);
        }
    });
    tableLayout.setColumnData(tvc.getColumn(), new ColumnWeightData(1));
}

From source file:net.tourbook.common.util.DialogModifyColumns.java

License:Open Source License

/**
 * Column: Category/*from   w  w w.  j a  v a2s. co m*/
 */
private void defineColumn_Category(final TableColumnLayout tableLayout) {

    if (_isCategoryAvailable) {

        final TableViewerColumn tvc = new TableViewerColumn(_columnViewer, SWT.LEAD);

        final TableColumn tc = tvc.getColumn();
        tc.setMoveable(true);
        tc.setText(Messages.ColumnModifyDialog_Column_Category);

        tvc.setLabelProvider(new CellLabelProvider() {
            @Override
            public void update(final ViewerCell cell) {

                final ColumnDefinition colDef = (ColumnDefinition) cell.getElement();
                cell.setText(colDef.getColumnCategory());

                setColor(cell, colDef);
            }
        });
        _categoryColumn = tc;

        _categoryColumnWidth = _pc.convertWidthInCharsToPixels(20);
        int categoryColumnWidth;
        if (_columnManager.isShowCategory()) {
            categoryColumnWidth = _categoryColumnWidth;
        } else {
            // hide column
            categoryColumnWidth = 0;
        }

        tableLayout.setColumnData(tc, new ColumnPixelData(categoryColumnWidth, true));
    }
}

From source file:net.tourbook.common.util.DialogModifyColumns.java

License:Open Source License

/**
 * Column: Label/*from  w w  w  .  jav a 2s .  c o m*/
 */
private void defineColumn_ColumnName(final TableColumnLayout tableLayout) {

    final TableViewerColumn tvc = new TableViewerColumn(_columnViewer, SWT.LEAD);

    final TableColumn tc = tvc.getColumn();
    tc.setMoveable(true);
    tc.setText(Messages.ColumnModifyDialog_column_column);

    tvc.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final ColumnDefinition colDef = (ColumnDefinition) cell.getElement();
            cell.setText(colDef.getColumnLabel());

            setColor(cell, colDef);
        }
    });
    tableLayout.setColumnData(tc, new ColumnWeightData(30, true));
}

From source file:net.tourbook.common.util.DialogModifyColumns.java

License:Open Source License

/**
 * Column: Format/* ww  w. j av  a 2  s. c  o m*/
 */
private void defineColumn_Format(final TableColumnLayout tableLayout) {

    final TableViewerColumn tvc = new TableViewerColumn(_columnViewer, SWT.LEAD);

    final TableColumn tc = tvc.getColumn();
    tc.setMoveable(true);
    tc.setText(Messages.ColumnModifyDialog_Column_FormatCategory);

    tvc.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {

            final ColumnDefinition colDef = (ColumnDefinition) cell.getElement();

            ValueFormat valueFormat = colDef.getValueFormat_Category();

            if (valueFormat == null) {
                valueFormat = colDef.getDefaultValueFormat_Category();
            }

            if (valueFormat == null) {
                cell.setText(UI.EMPTY_STRING);
            } else {
                cell.setText(ColumnManager.getValueFormatterName(valueFormat));
            }

            setColor(cell, colDef);
        }
    });
    tableLayout.setColumnData(tc, new ColumnPixelData(_pc.convertWidthInCharsToPixels(14), true));
}