Search in sources :

Example 1 with Parameter

use of org.talend.designer.rowgenerator.data.Parameter in project tdi-studio-se by Talend.

the class MetadataSchemaExt method initializeOneColumn.

@Override
@SuppressWarnings("unchecked")
protected IMetadataColumn initializeOneColumn(final IMetadataColumn metadataColumn, final NamedNodeMap nodeMap) {
    IMetadataColumn column = super.initializeOneColumn(metadataColumn, nodeMap);
    MetadataColumnExt columnExt = new MetadataColumnExt((MetadataColumn) column);
    //$NON-NLS-1$
    Node function = nodeMap.getNamedItem("function");
    if (function != null) {
        //$NON-NLS-1$
        Node parameter = nodeMap.getNamedItem("parameter");
        //$NON-NLS-1$
        Node preview = nodeMap.getNamedItem("preview");
        Function function2 = funManager.getCurrentFunction(function.getNodeValue(), columnExt);
        List<Parameter> parms = function2.getParameters();
        //$NON-NLS-1$
        String[] paraStr = parameter.getNodeValue().split(";");
        for (String string : paraStr) {
            //$NON-NLS-1$
            String[] nv = string.split("=>");
            for (Parameter para : parms) {
                if (para.getName().equals(nv[0].trim())) {
                    para.setValue(nv[1]);
                    break;
                }
            }
        }
        columnExt.setFunction(function2);
        columnExt.setPreview(preview.getNodeValue());
    } else {
        Function function2 = funManager.getDefaultFunction(columnExt, columnExt.getTalendType());
        columnExt.setFunction(function2);
        //$NON-NLS-1$
        columnExt.setPreview("");
    }
    return columnExt;
}
Also used : Function(org.talend.designer.rowgenerator.data.Function) Node(org.w3c.dom.Node) Parameter(org.talend.designer.rowgenerator.data.Parameter) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 2 with Parameter

use of org.talend.designer.rowgenerator.data.Parameter in project tdi-studio-se by Talend.

the class ExpressionComposite method setExpression.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.expressionbuilder.ui.ExpressionController#setExpression(org.talend.designer.rowgenerator.data.Function
     * )
     */
public void setExpression(Function f) {
    String newValue = PERL_FUN_PREFIX;
    if (f != null) {
        final List<Parameter> parameters = f.getParameters();
        if (FunctionManager.isJavaProject()) {
            String fullName = f.getName();
            //$NON-NLS-1$
            newValue = fullName + "(";
            for (Parameter pa : parameters) {
                newValue += pa.getValue() + FUN_PARAM_SEPARATED;
            }
            if (!parameters.isEmpty()) {
                newValue = newValue.substring(0, newValue.length() - 1);
            }
            //$NON-NLS-1$
            newValue += ")";
        } else {
            //$NON-NLS-1$
            newValue += f.getName() + "(";
            for (Parameter pa : parameters) {
                newValue += pa.getValue() + FUN_PARAM_SEPARATED;
            }
            newValue = newValue.substring(0, newValue.length() - 1);
            newValue += PERL_FUN_SUFFIX;
        }
    }
    IRegion region = viewer.getViewerRegion();
    try {
        document.replace(region.getOffset(), region.getLength(), newValue);
    } catch (BadLocationException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : Parameter(org.talend.designer.rowgenerator.data.Parameter) IRegion(org.eclipse.jface.text.IRegion) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 3 with Parameter

use of org.talend.designer.rowgenerator.data.Parameter in project tdi-studio-se by Talend.

the class PigExpressionComposite method setExpression.

@Override
public void setExpression(Function f) {
    String newValue = PERL_FUN_PREFIX;
    if (f != null) {
        final List<Parameter> parameters = f.getParameters();
        if (FunctionManager.isJavaProject()) {
            String fullName = f.getName();
            //$NON-NLS-1$
            newValue = fullName + "(";
            for (Parameter pa : parameters) {
                newValue += pa.getValue() + FUN_PARAM_SEPARATED;
            }
            if (!parameters.isEmpty()) {
                newValue = newValue.substring(0, newValue.length() - 1);
            }
            //$NON-NLS-1$
            newValue += ")";
        } else {
            //$NON-NLS-1$
            newValue += f.getName() + "(";
            for (Parameter pa : parameters) {
                newValue += pa.getValue() + FUN_PARAM_SEPARATED;
            }
            newValue = newValue.substring(0, newValue.length() - 1);
            newValue += PERL_FUN_SUFFIX;
        }
    }
    setExpression(newValue, true);
}
Also used : Parameter(org.talend.designer.rowgenerator.data.Parameter)

Example 4 with Parameter

use of org.talend.designer.rowgenerator.data.Parameter in project tdi-studio-se by Talend.

the class BatchExpressionComposite method setExpression.

@Override
public void setExpression(Function f) {
    String newValue = PERL_FUN_PREFIX;
    if (f != null) {
        final List<Parameter> parameters = f.getParameters();
        if (FunctionManager.isJavaProject()) {
            String fullName = f.getName();
            //$NON-NLS-1$
            newValue = fullName + "(";
            for (Parameter pa : parameters) {
                newValue += pa.getValue() + FUN_PARAM_SEPARATED;
            }
            if (!parameters.isEmpty()) {
                newValue = newValue.substring(0, newValue.length() - 1);
            }
            //$NON-NLS-1$
            newValue += ")";
        } else {
            //$NON-NLS-1$
            newValue += f.getName() + "(";
            for (Parameter pa : parameters) {
                newValue += pa.getValue() + FUN_PARAM_SEPARATED;
            }
            newValue = newValue.substring(0, newValue.length() - 1);
            newValue += PERL_FUN_SUFFIX;
        }
    }
    setExpression(newValue, true);
}
Also used : Parameter(org.talend.designer.rowgenerator.data.Parameter)

Example 5 with Parameter

use of org.talend.designer.rowgenerator.data.Parameter 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

Parameter (org.talend.designer.rowgenerator.data.Parameter)6 ListParameter (org.talend.designer.rowgenerator.data.ListParameter)2 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IRegion (org.eclipse.jface.text.IRegion)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 CCombo (org.eclipse.swt.custom.CCombo)1 TableEditor (org.eclipse.swt.custom.TableEditor)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Point (org.eclipse.swt.graphics.Point)1 Control (org.eclipse.swt.widgets.Control)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1 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 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)1