Example usage for org.eclipse.jface.viewers ComboBoxCellEditor getLayoutData

List of usage examples for org.eclipse.jface.viewers ComboBoxCellEditor getLayoutData

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ComboBoxCellEditor getLayoutData.

Prototype

@Override
public LayoutData getLayoutData() 

Source Link

Document

The ComboBoxCellEditor implementation of this CellEditor framework method sets the minimum width of the cell.

Usage

From source file:com.arm.cmsis.pack.tree.AdvisedEditingSupport.java

License:Apache License

@Override
protected CellEditor getCellEditor(final Object element) {

    //Log.writeCurrentMethod(element);

    final TreeViewer treeViewer = (TreeViewer) getViewer();

    switch (columnAdvisor.getCellControlType(element, columnIndex)) {
    case CHECK://from   w  w  w .ja  v  a2  s. c  o  m
        return new CheckboxCellEditor(treeViewer.getTree());
    case COMBO:
        final ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(treeViewer.getTree(),
                columnAdvisor.getStringArray(element, columnIndex), SWT.READ_ONLY) {

            @Override
            public LayoutData getLayoutData() {
                LayoutData ld = super.getLayoutData();
                ld.minimumWidth = 20;
                return ld;
            }
        };
        Control control = cellEditor.getControl();
        final CCombo combo = (CCombo) control;

        LayoutData ld = cellEditor.getLayoutData();
        ld.grabHorizontal = true;
        ld.horizontalAlignment = SWT.RIGHT;
        ld.verticalAlignment = SWT.CENTER;
        combo.setLayoutData(ld);

        combo.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                Integer newVal = new Integer(combo.getSelectionIndex());
                setValue(element, newVal);
            }
        });

        return cellEditor;
    default:
        break;
    }

    return null;
}

From source file:com.arm.cmsis.pack.ui.tree.AdvisedEditingSupport.java

License:Open Source License

@Override
protected CellEditor getCellEditor(final Object element) {
    Composite composite = (Composite) getViewer().getControl();

    switch (columnAdvisor.getCellControlType(element, columnIndex)) {
    case SPIN://  w  w w.  j av  a 2  s .  c  o m
        SpinnerCellEditor sce = new SpinnerCellEditor(composite);
        sce.getSpinner().setMinimum(0);
        sce.getSpinner().setMaximum(columnAdvisor.getMaxCount(element, columnIndex));
        return sce;
    case MENU:
        MenuCellEditor mce = new MenuCellEditor(composite);
        return mce;
    case CHECK:
        return new CheckboxCellEditor(composite);
    case COMBO:
        final ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(composite,
                columnAdvisor.getStringArray(element, columnIndex), SWT.READ_ONLY) {
            @Override
            public LayoutData getLayoutData() {
                LayoutData ld = super.getLayoutData();
                ld.minimumWidth = 20;
                return ld;
            }
        };
        Control control = cellEditor.getControl();
        final CCombo combo = (CCombo) control;

        LayoutData ld = cellEditor.getLayoutData();
        ld.grabHorizontal = true;
        ld.horizontalAlignment = SWT.RIGHT;
        ld.verticalAlignment = SWT.CENTER;
        combo.setLayoutData(ld);

        combo.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                Integer newVal = new Integer(combo.getSelectionIndex());
                setValue(element, newVal);
            }
        });

        return cellEditor;
    default:
        break;
    }

    return null;
}