Search in sources :

Example 96 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class DynamicTabbedPropertySection method updateQuery.

@SuppressWarnings("unchecked")
private void updateQuery() {
    Object propertyValue = elem.getPropertyValue(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName());
    if (//$NON-NLS-1$
    propertyValue == null || !(propertyValue instanceof String) || "".equals(propertyValue) || elem.getPropertyValue(EParameterName.QUERYSTORE_TYPE.getName()).equals(EmfComponent.BUILTIN)) {
        return;
    }
    if (repositoryQueryStoreMap.containsKey(propertyValue)) {
        Query query = repositoryQueryStoreMap.get(propertyValue);
        for (IElementParameter param : (List<IElementParameter>) elem.getElementParameters()) {
            if (param.getFieldType() == EParameterFieldType.MEMO_SQL) {
                elem.setPropertyValue(param.getName(), convertSQL(query.getValue()));
                param.setRepositoryValueUsed(true);
            }
        }
    }
}
Also used : Query(org.talend.core.model.metadata.builder.connection.Query) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ContentList(org.talend.commons.utils.data.container.ContentList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 97 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class DynamicTabbedPropertySection method updateProcessList.

/**
     * ftang Comment method "updateProcessList".
     */
private void updateProcessList() {
    List<String> processNameList = new ArrayList<String>();
    List<String> processValueList = new ArrayList<String>();
    processMap = new HashMap<String, IRepositoryViewObject>();
    IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
    try {
        RootContainer<String, IRepositoryViewObject> processContainer = factory.getMetadata(ERepositoryObjectType.PROCESS);
        ContentList<String, IRepositoryViewObject> processAbsoluteMembers = processContainer.getAbsoluteMembers();
        String currentProcess = part.getTalendEditor().getProcess().getLabel();
        for (Content<String, IRepositoryViewObject> object : processAbsoluteMembers.values()) {
            IRepositoryViewObject process = object.getContent();
            if (factory.getStatus(process) != ERepositoryStatus.DELETED && !currentProcess.equals(process.getLabel())) {
                String path = object.getParent().getPath().toString();
                String name;
                if (path.equals("")) {
                    //$NON-NLS-1$
                    name = IPath.SEPARATOR + process.getLabel();
                } else {
                    name = IPath.SEPARATOR + path + IPath.SEPARATOR + process.getLabel();
                }
                processNameList.add(name);
                processMap.put(name, process);
            }
        }
    } catch (PersistenceException e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    List<String> tempFolderList = new ArrayList<String>();
    List<String> tempProcessNameList = new ArrayList<String>();
    tempProcessNameList.addAll(processNameList);
    for (String string : tempProcessNameList) {
        // Put jobs which in a folder into a new list.s
        if (string.lastIndexOf("/") != 0) {
            //$NON-NLS-1$
            tempFolderList.add(string);
            processNameList.remove(string);
        }
    }
    sortList(processNameList);
    sortList(tempFolderList);
    // Always put the jobs which in a folder on the top of the job list
    tempFolderList.addAll(processNameList);
    processNameList = tempFolderList;
    for (String name : processNameList) {
        IRepositoryViewObject process = processMap.get(name);
        processValueList.add(process.getLabel());
    }
    String[] processTableNameList = processNameList.toArray(new String[0]);
    String[] processTableValueList = processValueList.toArray(new String[0]);
    for (int i = 0; i < elem.getElementParameters().size(); i++) {
        IElementParameter param = elem.getElementParameters().get(i);
        if (param.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
            param.setListItemsDisplayName(processTableNameList);
            param.setListItemsValue(processTableValueList);
            if (elem instanceof Node) {
                ((Node) elem).checkAndRefreshNode();
            }
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 98 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class DynamicTabbedPropertySection method updateContextList.

/**
     * ftang Comment method "updateContextList".
     */
private void updateContextList() {
    List<String> contextNameList = new ArrayList<String>();
    List<String> contextValueList = new ArrayList<String>();
    IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
    String selectedProcess = null;
    for (int i = 0; (i < elem.getElementParameters().size()) && (selectedProcess == null); i++) {
        IElementParameter param = elem.getElementParameters().get(i);
        if (param.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
            selectedProcess = (String) param.getValue();
        }
    }
    if (selectedProcess == null) {
        return;
    }
    try {
        List<IRepositoryViewObject> list = factory.getAll(ERepositoryObjectType.PROCESS);
        for (IRepositoryViewObject process : list) {
            String id = process.getLabel();
            if (selectedProcess.equals(id)) {
                if (process.getProperty().getItem() instanceof ProcessItem) {
                    ProcessItem processItem = (ProcessItem) process.getProperty().getItem();
                    for (Object o : processItem.getProcess().getContext()) {
                        if (o instanceof ContextType) {
                            ContextType context = (ContextType) o;
                            contextNameList.add(context.getName());
                            contextValueList.add(context.getName());
                        }
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    String[] contextTableNameList = contextNameList.toArray(new String[0]);
    String[] contextTableValueList = contextValueList.toArray(new String[0]);
    for (int i = 0; i < elem.getElementParameters().size(); i++) {
        IElementParameter param = elem.getElementParameters().get(i);
        if (param.getName().equals(EParameterName.PROCESS_TYPE_CONTEXT.getName())) {
            param.setListItemsDisplayName(contextTableNameList);
            param.setListItemsValue(contextTableValueList);
            if (!contextValueList.contains(param.getValue())) {
                if (contextTableNameList.length > 0) {
                    elem.setPropertyValue(EParameterName.PROCESS_TYPE_CONTEXT.getName(), contextTableValueList[0]);
                }
            } else {
                // force to store the value again to activate the code
                // generation in Node.setPropertyValue
                elem.setPropertyValue(EParameterName.PROCESS_TYPE_CONTEXT.getName(), param.getValue());
            }
        }
    }
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 99 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class StatsAndLogsHelper method statsAndLogsParametersFinalPart.

private static void statsAndLogsParametersFinalPart(Element elem) {
    ElementParameter param;
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    //$NON-NLS-1$
    String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
    // Catch runtime errors
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_RUNTIME_ERRORS");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_RUNTIME_ERRORS.getName()));
    param.setDisplayName(EParameterName.CATCH_RUNTIME_ERRORS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(90);
    //$NON-NLS-1$
    param.setShowIf("ON_LOGCATCHER_FLAG == 'true'");
    paramList.add(param);
    // Catch user errors
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_USER_ERRORS");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_USER_ERRORS.getName()));
    param.setDisplayName(EParameterName.CATCH_USER_ERRORS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(90);
    //$NON-NLS-1$
    param.setShowIf("ON_LOGCATCHER_FLAG == 'true'");
    paramList.add(param);
    // Catch user warning
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_USER_WARNING");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_USER_WARNING.getName()));
    param.setDisplayName(EParameterName.CATCH_USER_WARNING.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(90);
    //$NON-NLS-1$
    param.setShowIf("ON_LOGCATCHER_FLAG == 'true'");
    paramList.add(param);
    // Catch realtime statistics
    param = new ElementParameter(elem);
    //$NON-NLS-1$
    param.setName("CATCH_REALTIME_STATS");
    param.setValue(preferenceStore.getBoolean(languagePrefix + EParameterName.CATCH_REALTIME_STATS.getName()));
    param.setDisplayName(//$NON-NLS-1$
    EParameterName.CATCH_REALTIME_STATS.getDisplayName() + " (" + EParameterName.TSTATCATCHER_STATS.getDisplayName() + //$NON-NLS-1$
    ")");
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(91);
    //$NON-NLS-1$
    param.setShowIf("ON_STATCATCHER_FLAG == 'true'");
    paramList.add(param);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 100 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class ProjectSettingManager method createImplicitContextLoadParameters.

/**
     *
     * create parameter for ImplicitContextLoad.
     */
static void createImplicitContextLoadParameters(Element elem) {
    ElementParameter param;
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    param = new ElementParameter(elem);
    param.setName(EParameterName.UPDATE_COMPONENTS.getName());
    param.setValue(Boolean.FALSE);
    param.setDisplayName(EParameterName.UPDATE_COMPONENTS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(1);
    param.setReadOnly(true);
    param.setRequired(false);
    param.setShow(false);
    paramList.add(param);
    param = new ElementParameter(elem);
    param.setName(EParameterName.IMPLICIT_TCONTEXTLOAD.getName());
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.IMPLICIT_TCONTEXTLOAD)));
    param.setGroupDisplayName(EParameterName.IMPLICIT_TCONTEXTLOAD.getDisplayName());
    param.setDisplayName(EParameterName.IMPLICIT_TCONTEXTLOAD.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setGroup(IMPLICIT_GROUP);
    param.setNumRow(3);
    param.setShow(true);
    paramList.add(param);
    param = new ElementParameter(elem);
    param.setName(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName());
    param.setValue(Boolean.TRUE);
    param.setGroupDisplayName(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getDisplayName());
    param.setDisplayName(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setGroup(IMPLICIT_GROUP);
    param.setNumRow(3);
    param.setShow(false);
    paramList.add(param);
    // on files
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName()));
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.FROM_FILE_FLAG)));
    param.setDisplayName(EParameterName.FROM_FILE_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.RADIO);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(4);
    param.setShowIf(JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION));
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // on database
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName()));
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.FROM_DATABASE_FLAG)));
    param.setDisplayName(EParameterName.FROM_DATABASE_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.RADIO);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(5);
    param.setShowIf(JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION));
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // on file
    createExtraOnFileParameters(elem);
    // on database
    createExtraOnDBParameters(elem);
    // tContextLoad
    createExtraContextLoadParameters(elem);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

IElementParameter (org.talend.core.model.process.IElementParameter)439 ArrayList (java.util.ArrayList)165 List (java.util.List)112 Node (org.talend.designer.core.ui.editor.nodes.Node)108 Map (java.util.Map)99 INode (org.talend.core.model.process.INode)94 HashMap (java.util.HashMap)87 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)73 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)69 Point (org.eclipse.swt.graphics.Point)57 ElementParameter (org.talend.designer.core.model.components.ElementParameter)48 ConnectionItem (org.talend.core.model.properties.ConnectionItem)45 IConnection (org.talend.core.model.process.IConnection)40 PersistenceException (org.talend.commons.exception.PersistenceException)39 Item (org.talend.core.model.properties.Item)38 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)37 IComponent (org.talend.core.model.components.IComponent)36 CCombo (org.eclipse.swt.custom.CCombo)33 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)29 Connection (org.talend.core.model.metadata.builder.connection.Connection)28