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;
}
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);
}
}
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);
}
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);
}
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()));
// ////////////////////////////////////////////////////////
}
Aggregations