Search in sources :

Example 1 with ExtendedTextCellEditorWithProposal

use of org.talend.commons.ui.swt.proposal.ExtendedTextCellEditorWithProposal in project tdi-studio-se by Talend.

the class FunParaTableView2 method createColumns.

@Override
protected void createColumns(TableViewerCreator<Parameter> tableViewerCreator, final Table table) {
    this.tableViewerCreator = tableViewerCreator;
    IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
    TableViewerCreatorColumn column;
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("FunParaTableView2.Parameter"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {

        public String get(Parameter bean) {
            return bean.getName();
        }

        public void set(Parameter bean, Object value) {
        }
    });
    column.setModifiable(false);
    column.setWidth(115);
    // column.setCellEditor(new
    // TextCellEditor(tableViewerCreator.getTable()));
    // ////////////////////////////////////////////////////////
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("FunParaTableView2.Value"));
    column.setId(VALUE_PROPERTY);
    CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
    cellEditor = new ExtendedTextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.MULTI | SWT.BORDER, column, behavior);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {

        public String get(Parameter bean) {
            StringBuffer id = new StringBuffer();
            //$NON-NLS-1$
            id.append(component.getLabel() + "=>");
            TableItem[] item = rowGenTableEditor2.getTable().getSelection();
            if (item.length == 1) {
                //$NON-NLS-1$
                id.append(((MetadataColumnExt) item[0].getData()).getLabel() + "=>");
            }
            cellEditor.setOwnerId(id.append(bean.getName()).toString());
            cellEditor.setExpressionType(bean.getType());
            String valueTemp = bean.getValue();
            if (valueTemp != null && !valueTemp.endsWith(" ")) {
                bean.setValue(valueTemp + " ");
            }
            return bean.getValue();
        }

        public void set(Parameter bean, Object value) {
            if (value == null) {
                return;
            }
            String valueTemp = value.toString();
            if (!valueTemp.endsWith(" ")) {
                value = value + " ";
            }
            bean.setValue(value.toString());
            if (ext != null) {
                ext.setChanged(true);
            }
            if (!rowGenTableEditor2.getTableViewerCreator().getTableViewer().isCellEditorActive()) {
                rowGenTableEditor2.getTableViewerCreator().getTableViewer().refresh();
            }
        }
    });
    column.setModifiable(true);
    column.setWidth(115);
    dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(mainComposite, cellEditor, component);
    behavior.setCellEditorDialog(dialog);
    cellEditor.setContentProposalProvider(getProcessProposals());
    //$NON-NLS-1$
    cellEditor.setExpressionType("String");
    column.setCellEditor(cellEditor);
    // ////////////////////////////////////////////////////////
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("FunParaTableView2.Comment"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {

        public String get(Parameter bean) {
            return bean.getComment();
        }

        public void set(Parameter bean, Object value) {
        }
    });
    column.setModifiable(false);
    column.setWidth(155);
// column.setCellEditor(new
// TextCellEditor(tableViewerCreator.getTable()));
// ////////////////////////////////////////////////////////
}
Also used : ExtendedTextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.ExtendedTextCellEditorWithProposal) CellEditorDialogBehavior(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior) Parameter(org.talend.designer.rowgenerator.data.Parameter) ListParameter(org.talend.designer.rowgenerator.data.ListParameter) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) IService(org.talend.core.IService)

Aggregations

CellEditorDialogBehavior (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior)1 ExtendedTextCellEditorWithProposal (org.talend.commons.ui.swt.proposal.ExtendedTextCellEditorWithProposal)1 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)1 IService (org.talend.core.IService)1 ListParameter (org.talend.designer.rowgenerator.data.ListParameter)1 Parameter (org.talend.designer.rowgenerator.data.Parameter)1