Search in sources :

Example 41 with IContext

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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) IContext(org.talend.core.model.process.IContext) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo)

Example 42 with IContext

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;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IContext(org.talend.core.model.process.IContext) List(java.util.List) ArrayList(java.util.ArrayList) IContextManager(org.talend.core.model.process.IContextManager)

Example 43 with IContext

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());
            }
        }
        */
}
Also used : IContext(org.talend.core.model.process.IContext) ProcessManager(org.talend.designer.runprocess.ui.ProcessManager)

Example 44 with IContext

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;
    }
}
Also used : IContext(org.talend.core.model.process.IContext) HashMap(java.util.HashMap) ContextParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ContextTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl) JobContext(org.talend.core.model.context.JobContext) HashSet(java.util.HashSet)

Example 45 with IContext

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();
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) IContext(org.talend.core.model.process.IContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ContextParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl) RepositoryNode(org.talend.repository.model.RepositoryNode) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) EList(org.eclipse.emf.common.util.EList) Iterator(java.util.Iterator) IProcess2(org.talend.core.model.process.IProcess2) ContextTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl) IContextManager(org.talend.core.model.process.IContextManager) IEditorInput(org.eclipse.ui.IEditorInput) HashSet(java.util.HashSet)

Aggregations

IContext (org.talend.core.model.process.IContext)46 IContextParameter (org.talend.core.model.process.IContextParameter)14 ArrayList (java.util.ArrayList)13 List (java.util.List)11 IProcess (org.talend.core.model.process.IProcess)10 ProcessorException (org.talend.designer.runprocess.ProcessorException)10 HashMap (java.util.HashMap)9 ProcessItem (org.talend.core.model.properties.ProcessItem)8 IOException (java.io.IOException)7 IElementParameter (org.talend.core.model.process.IElementParameter)7 IProcessor (org.talend.designer.runprocess.IProcessor)7 File (java.io.File)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IContextManager (org.talend.core.model.process.IContextManager)6 HashSet (java.util.HashSet)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IProcess2 (org.talend.core.model.process.IProcess2)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 Map (java.util.Map)4