use of org.talend.core.model.process.IContextParameter in project tdi-studio-se by Talend.
the class TalendJavaSourceViewer method createViewerWithVariables.
public static ReconcilerViewer createViewerWithVariables(Composite composite, int styles, IExpressionDataBean dataBean) {
IDocument document = new Document();
StringBuffer buff = new StringBuffer();
//$NON-NLS-1$
buff.append("\npackage internal;\n\n");
buff.append(getImports());
//$NON-NLS-1$ //$NON-NLS-2$
buff.append("public class " + VIEWER_CLASS_NAME + currentId + " {\n");
IRunProcessService runProcessService = getRunProcessService();
if (runProcessService != null && runProcessService.getSelectedContext() != null) {
List<IContextParameter> params = runProcessService.getSelectedContext().getContextParameterList();
buff.append(TEXT_1);
for (IContextParameter ctxParam : params) {
buff.append(TEXT_2);
buff.append(ctxParam.getName());
buff.append(TEXT_3);
buff.append(ctxParam.getName());
buff.append(TEXT_4);
}
buff.append(TEXT_5);
for (IContextParameter ctxParam : params) {
if (//$NON-NLS-1$ //$NON-NLS-2$
ctxParam.getType().equals("id_List Of Value") || ctxParam.getType().equals("id_File") || ctxParam.getType().equals("id_Directory") || ctxParam.getType().equals("id_Character")) {
//$NON-NLS-1$ //$NON-NLS-2$
buff.append(TEXT_6);
buff.append(ctxParam.getName());
buff.append(TEXT_7);
} else {
buff.append(TEXT_8);
buff.append(JavaTypesManager.getTypeToGenerate(ctxParam.getType(), true));
buff.append(TEXT_9);
buff.append(ctxParam.getName());
buff.append(TEXT_10);
}
}
buff.append(TEXT_11);
//$NON-NLS-1$
buff.append("\tprivate static ContextProperties context = new ContextProperties();\n");
//$NON-NLS-1$
buff.append("\tprivate static final java.util.Map<String, Object> globalMap = new java.util.HashMap<String, Object>();\n");
if (dataBean != null) {
buff.append(parseVariables(dataBean.getVariables()));
//$NON-NLS-1$ //$NON-NLS-2$
buff.append("\tpublic " + dataBean.getExpressionType() + " myFunction(){\n");
}
//$NON-NLS-1$
buff.append("\t\treturn \n");
}
int length = buff.toString().length();
//$NON-NLS-1$
String defaultValue = "";
//$NON-NLS-1$
buff.append(defaultValue + "\n;\t\n}\n}");
document.set(buff.toString());
return initializeViewer(composite, styles, true, document, length);
}
use of org.talend.core.model.process.IContextParameter in project tdi-studio-se by Talend.
the class ProcessContextComposite method checkIsSameContextParameter.
/*
* check same ContextParameter or not.
*/
private boolean checkIsSameContextParameter() {
List<ContextItem> allContextItem = ContextUtils.getAllContextItem();
for (IContext context : process.getContextManager().getListContext()) {
for (IContextParameter param : context.getContextParameterList()) {
if (allContextItem != null) {
ContextItem contextItem = ContextUtils.getContextItemById(allContextItem, param.getSource());
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, context.getName(), true);
ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(contextType, param.getName());
if (!ContextUtils.samePropertiesForContextParameter(param, contextParameterType)) {
return false;
}
// if don't open the job to run it(not use the "Detect and update all jobs"), will show
// UpdateDetectionDialog to update the context ,after updated the item, the contextComboViewer still
// set the old one , so need refresh.
IContext runJobViewContext = getSelectedContext();
if (runJobViewContext != null) {
for (IContextParameter tempContext : runJobViewContext.getContextParameterList()) {
if (tempContext.getName().equals(contextParameterType.getName()) && !ContextUtils.samePropertiesForContextParameter(tempContext, contextParameterType)) {
return false;
}
}
}
}
}
}
return true;
}
use of org.talend.core.model.process.IContextParameter in project tdi-studio-se by Talend.
the class ProcessContextComposite method promptConfirmLauch.
public static boolean promptConfirmLauch(Shell shell, IContext context, IProcess process) {
boolean continueLaunch = true;
int nbValues = 0;
if (context == null) {
//$NON-NLS-1$
throw new IllegalArgumentException("Context is null");
}
// Prompt for context values ?
for (IContextParameter parameter : context.getContextParameterList()) {
if (parameter.isPromptNeeded()) {
nbValues++;
}
}
if (nbValues > 0) {
IContext contextCopy = context.clone();
PromptDialog promptDialog = new PromptDialog(shell, contextCopy);
if (promptDialog.open() == PromptDialog.OK) {
for (IContextParameter param : context.getContextParameterList()) {
boolean found = false;
IContextParameter paramCopy = null;
for (int i = 0; i < contextCopy.getContextParameterList().size() & !found; i++) {
paramCopy = contextCopy.getContextParameterList().get(i);
if (param.getName().equals(paramCopy.getName())) {
// param.setValueList(paramCopy.getValueList());
param.setInternalValue(paramCopy.getValue());
found = true;
}
}
}
contextComboViewer.refresh();
contextTableViewer.refresh();
processNeedGenCode(process);
} else {
continueLaunch = false;
}
} else {
if (context.isConfirmationNeeded()) {
continueLaunch = //$NON-NLS-1$
MessageDialog.openQuestion(//$NON-NLS-1$
shell, //$NON-NLS-1$
Messages.getString("ProcessComposite.confirmTitle"), //$NON-NLS-1$
Messages.getString("ProcessComposite.confirmText", context.getName()));
}
updateDefaultValueForListTypeParameter(context.getContextParameterList());
}
return continueLaunch;
}
use of org.talend.core.model.process.IContextParameter in project tesb-studio-se by Talend.
the class ContextPartGenerator method tranformEncryptedParams.
private static List<IContextParameter> tranformEncryptedParams(List<IContextParameter> listParameters) {
List<IContextParameter> listParametersCopy = new ArrayList<IContextParameter>(listParameters.size());
// encrypt the password
for (IContextParameter iContextParameter : listParameters) {
if (PasswordEncryptUtil.isPasswordType(iContextParameter.getType())) {
IContextParameter icp = iContextParameter.clone();
String pwd = icp.getValue();
if (pwd != null && !pwd.isEmpty()) {
try {
icp.setValue(PasswordEncryptUtil.encryptPasswordHex(pwd));
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
listParametersCopy.add(icp);
} else {
listParametersCopy.add(iContextParameter);
}
}
return listParametersCopy;
}
use of org.talend.core.model.process.IContextParameter in project tdi-studio-se by Talend.
the class TestComponentsAction method setDefaultProperties.
/**
* DOC qwei Comment method "setDefaultProperties".
*
* @param process
*/
private void setDefaultProperties(IProcess process, String componentPath) {
// input_path / output_path
IContext context = process.getContextManager().getDefaultContext();
List<IContextParameter> tempContextParameter = context.getContextParameterList();
for (IContextParameter parameter : tempContextParameter) {
fillParameter(parameter, componentPath);
}
}
Aggregations