use of org.talend.core.model.process.IContext in project tdi-studio-se by Talend.
the class ConfigureConnParamDialog method createContextComposite.
/**
* qzhang Comment method "createContextComposite".
*
* @return
*/
private IContext createContextComposite(Composite parent) {
Composite contextComposite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false);
contextComposite.setLayout(gridLayout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
contextComposite.setLayoutData(gridData);
Label contextLabel = new Label(contextComposite, SWT.NONE);
//$NON-NLS-1$
contextLabel.setText(Messages.getString("ConfigureConnParamDialog.ContextLabel"));
contextCombo = new Combo(contextComposite, SWT.PUSH);
GridDataFactory.swtDefaults().hint(LABEL_DEFAULT_X, DEFAULT_HEIGHT).applyTo(contextCombo);
contextCombo.setItems(getContextNames());
contextCombo.select(0);
IContext defaultContext = contextManager.getDefaultContext();
return defaultContext;
}
use of org.talend.core.model.process.IContext in project tdi-studio-se by Talend.
the class RepositoryWebService method parseContextParameter.
private String parseContextParameter(String contextValue) {
String url = "";
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
IContextManager contextManager = connector.getProcess().getContextManager();
String currentDefaultName = contextManager.getDefaultContext().getName();
List contextList = contextManager.getListContext();
if (!contextList.isEmpty() && contextList.size() > 1) {
currentDefaultName = ConnectionContextHelper.getContextTypeForJob(shell, contextManager, false);
}
// ContextSetsSelectionDialog cssd=new ContextSetsSelectionDialog(shell,,false);
// ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connector);
IContext context = contextManager.getContext(currentDefaultName);
url = ContextParameterUtils.parseScriptContextCode(contextValue, context);
return url;
}
use of org.talend.core.model.process.IContext in project tesb-studio-se by Talend.
the class RunESBRuntimeProcess method applyContextConfiguration.
private void applyContextConfiguration(String configID) throws Exception {
ProcessManager processManager = ProcessManager.getInstance();
IContext context = processManager.getSelectContext();
String contextName = context.getName();
JMXUtil.deleteConfigProperties(configID);
JMXUtil.setConfigProperty(configID, "context", contextName);
/*
// The following code is only required if context parameters are
// to be modified dynamically at deployment into local runtime.
// Such functionaliy is currently not implemented in Talend Studio,
// but contexts are applied as generated.
List<org.talend.core.model.process.IContextParameter> params = context.getContextParameterList();
if (params != null) {
for (org.talend.core.model.process.IContextParameter param : params) {
String name = param.getName();
if ("context".equals(name)) {
continue;
}
JMXUtil.setConfigProperty(configID, name, param.getValue());
}
}
*/
}
use of org.talend.core.model.process.IContext in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method checkAndAddContextVariables.
public static void checkAndAddContextVariables(ContextItem item, IContextManager contextManager, Set<String> addedVars, Set<String> contextGoupNameSet) {
EList context = item.getContext();
Map<String, List<ContextParameterTypeImpl>> map = new HashMap<String, List<ContextParameterTypeImpl>>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
ContextTypeImpl contextTypeImpl = (ContextTypeImpl) obj;
String name = contextTypeImpl.getName();
EList contextParameters = contextTypeImpl.getContextParameter();
Iterator contextParas = contextParameters.iterator();
List<ContextParameterTypeImpl> list = new ArrayList<ContextParameterTypeImpl>();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
list.add(contextParameterType);
}
map.put(name, list);
}
}
if (map.isEmpty()) {
return;
}
String defaultContextName = item.getDefaultContext();
Set<String> existGroupNameSet = new HashSet<String>();
for (IContext con : contextManager.getListContext()) {
existGroupNameSet.add(con.getName());
}
if (contextGoupNameSet.isEmpty()) {
contextGoupNameSet.add(defaultContextName);
}
Set<String> alreadyUpdateNameSet = new HashSet<String>();
for (String key : map.keySet()) {
for (String groupName : contextGoupNameSet) {
boolean isExtraGroup = false;
for (String existGroup : existGroupNameSet) {
if (key.equals(existGroup)) {
isExtraGroup = true;
alreadyUpdateNameSet.add(existGroup);
break;
}
}
if (key.equals(groupName) || isExtraGroup) {
List<ContextParameterTypeImpl> list = map.get(key);
JobContext jobContext = new JobContext(key);
boolean isExistContext = false;
if (isExtraGroup) {
for (IContext con : contextManager.getListContext()) {
if (key.equals(con.getName())) {
if (con instanceof JobContext) {
jobContext = (JobContext) con;
isExistContext = true;
break;
}
}
}
}
setContextParameter(item, addedVars, list, jobContext);
if (!isExistContext) {
contextManager.getListContext().add(jobContext);
}
break;
}
}
}
// if job context group is not in current add's context,then update context group value to default group value
existGroupNameSet.removeAll(alreadyUpdateNameSet);
List<ContextParameterTypeImpl> list = map.get(defaultContextName);
if (list == null) {
return;
}
}
use of org.talend.core.model.process.IContext in project tesb-studio-se by Talend.
the class CamelEditorDropTargetListener method createContext.
private void createContext() {
if (selectSourceList.size() == 0) {
return;
}
boolean created = false;
for (Object source : selectSourceList) {
if (source instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) source;
Item item = sourceNode.getObject().getProperty().getItem();
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
EList context = contextItem.getContext();
Set<String> contextSet = new HashSet<String>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
EList contextParameters = ((ContextTypeImpl) obj).getContextParameter();
Iterator contextParas = contextParameters.iterator();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
String name = contextParameterType.getName();
contextSet.add(name);
}
}
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
IContextManager contextManager = process.getContextManager();
List<IContext> listContext = contextManager.getListContext();
Set<String> addedVars = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, process.getContextManager(), false);
if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem, contextManager, contextSet)) {
// show
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
addedVarsMap.put(item.getProperty().getLabel(), contextSet);
if (ConnectionContextHelper.showContextdialog(process, contextItem, process.getContextManager(), addedVarsMap, contextSet)) {
created = true;
}
} else {
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
editor.getEditorSite().getShell(), //$NON-NLS-1$
"Adding Context", //$NON-NLS-1$
"Context \"" + contextItem.getProperty().getDisplayName() + "\" already exist.");
}
}
}
}
}
if (created) {
RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
}
}
Aggregations