Search in sources :

Example 21 with Element

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

the class ComponentSettings method switchToCurComponentSettingsView.

public static void switchToCurComponentSettingsView() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewPart view = page.findView(ComponentSettingsView.ID);
    if (view == null) {
        // don't do anything. before it made the view appear for nothing even in other product like DQ.
        return;
    }
    if (view != null && view instanceof ComponentSettingsView) {
        ComponentSettingsView settingView = (ComponentSettingsView) view;
        Element element = settingView.getElement();
        if (element != null) {
            settingView.cleanDisplay();
            settingView.setElement(element);
        }
    }
    List<ComponentSettingsView> otherViews = JobTemplateViewsAndProcessUtil.getInstance().getAllViews();
    if (otherViews == null || otherViews.isEmpty()) {
        return;
    }
    for (ComponentSettingsView v : otherViews) {
        if (v.getParent() != null && !v.getParent().isDisposed()) {
            Element elem = v.getElement();
            if (elem != null) {
                v.cleanDisplay();
                v.setElement(elem);
            }
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) Element(org.talend.core.model.process.Element) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 22 with Element

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

the class MissingSettingsMultiThreadDynamicComposite method afterChangingLibraries.

@Override
public void afterChangingLibraries() {
    final Element ele = this.getElement();
    if (ele instanceof Node) {
        final Node node = (Node) ele;
        // after install, need update the error marks for node
        IProcess process = node.getProcess();
        if (process instanceof IProcess2) {
            // check whole process to make sure other related nodes can be updated also.
            ((IProcess2) process).checkProcess();
        }
    }
}
Also used : Element(org.talend.core.model.process.Element) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcess2(org.talend.core.model.process.IProcess2) IProcess(org.talend.core.model.process.IProcess)

Example 23 with Element

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

the class ElementParameter2ParameterType method loadElementParameters.

/**
     *
     * load the Element's parameters to EMF Model
     *
     * @param elemParam
     * @param paType
     */
public static void loadElementParameters(Element elemParam, ParametersType paType, String repParamName) {
    if (paType == null || elemParam == null) {
        return;
    }
    EList listParamType = paType.getElementParameter();
    ElementParameterType repositoryParam = null;
    if (repParamName != null && !repParamName.equals("")) {
        repositoryParam = findElementParameterType(paType, repParamName);
    } else {
        repositoryParam = findElementParameterType(paType, EParameterName.PROPERTY_TYPE.getName() + ":" + EParameterName.PROPERTY_TYPE.getName());
    }
    IElementParameter statsDBType = null;
    IElementParameter implicitDBType = null;
    IElementParameter statsDBVersion = null;
    IElementParameter implicitDBVersion = null;
    Element defaultElement = getDefaultElement(paType);
    for (int j = 0; j < listParamType.size(); j++) {
        ElementParameterType pType = (ElementParameterType) listParamType.get(j);
        if (pType != null) {
            String pTypeName = pType.getName();
            if (pTypeName != null && !"".equals(pTypeName)) {
                IElementParameter param = elemParam.getElementParameter(pTypeName);
                IElementParameter defalutParam = defaultElement.getElementParameter(pTypeName);
                if (defalutParam == null) {
                    continue;
                }
                if (pTypeName.equals("DB_TYPE")) {
                    //$NON-NLS-1$
                    statsDBType = param;
                } else if (pTypeName.equals("DB_VERSION")) {
                    //$NON-NLS-1$
                    statsDBVersion = param;
                } else if (pTypeName.equals("DB_TYPE_IMPLICIT_CONTEXT")) {
                    //$NON-NLS-1$
                    implicitDBType = param;
                } else if (pTypeName.equals("DB_VERSION_IMPLICIT_CONTEXT")) {
                    //$NON-NLS-1$
                    implicitDBVersion = param;
                }
                if (param != null) {
                    String name = param.getName();
                    param.setContextMode(pType.isContextMode());
                    if (param.isReadOnly() && !(EParameterName.UNIQUE_NAME.getName().equals(name) || EParameterName.VERSION.getName().equals(name))) {
                        // if the parameter is read only, don't load
                        continue;
                    // it (this will prevent to overwrite the
                    // value)
                    }
                    String value = null;
                    if (//$NON-NLS-1$
                    "STATANDLOG_USE_PROJECT_SETTINGS".equals(name) || "IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(name)) {
                        //$NON-NLS-1$
                        Object value2 = param.getValue();
                        if (value2 != null) {
                            value = value2.toString();
                        }
                    } else {
                        value = pType.getValue();
                    }
                    if (param.getFieldType().equals(EParameterFieldType.CHECK) || param.getFieldType().equals(EParameterFieldType.RADIO)) {
                        if (Boolean.FALSE.toString().equalsIgnoreCase(value) || Boolean.TRUE.toString().equalsIgnoreCase(value) || !pType.isContextMode()) {
                            Boolean boolean1 = new Boolean(value);
                            elemParam.setPropertyValue(pTypeName, boolean1);
                        } else {
                            elemParam.setPropertyValue(pTypeName, value);
                        }
                    // if (EParameterName.ACTIVATE.getName().equals(param.getName())) {
                    // if ((elemParam instanceof Node) && !boolean1) {
                    // ((Node) elemParam).setDummy(!boolean1);
                    // }
                    // }
                    } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
                        boolean valueSet = false;
                        if (!ArrayUtils.contains(param.getListItemsValue(), value)) {
                            if (ArrayUtils.contains(param.getListItemsDisplayName(), value)) {
                                valueSet = true;
                                int index = ArrayUtils.indexOf(param.getListItemsDisplayName(), value);
                                if (index > -1) {
                                    elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[index]);
                                }
                            } else if (value.equals("") && name != null && (name.equals("LOAD_NEW_VARIABLE") || name.equals("NOT_LOAD_OLD_VARIABLE"))) {
                                valueSet = true;
                                elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[1]);
                            }
                        }
                        if (!valueSet) {
                            elemParam.setPropertyValue(pTypeName, value);
                        }
                    } else if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
                        List<Map<String, Object>> tableValues = new ArrayList<Map<String, Object>>();
                        String[] codeList = param.getListItemsDisplayCodeName();
                        Map<String, Object> lineValues = null;
                        for (ElementValueType elementValue : (List<ElementValueType>) pType.getElementValue()) {
                            boolean found = false;
                            int length = codeList.length;
                            if (length > 0) {
                                for (int i = 0; i < length && !found; i++) {
                                    if (codeList[i].equals(elementValue.getElementRef())) {
                                        found = true;
                                    }
                                }
                            }
                            IElementParameter tmpParam = null;
                            for (Object o : param.getListItemsValue()) {
                                if (o instanceof IElementParameter) {
                                    IElementParameter tableParam = (IElementParameter) o;
                                    if (tableParam.getName().equals(elementValue.getElementRef())) {
                                        tmpParam = tableParam;
                                        break;
                                    }
                                }
                            }
                            if (found) {
                                if ((lineValues == null) || (lineValues.get(elementValue.getElementRef()) != null)) {
                                    lineValues = new HashMap<String, Object>();
                                    tableValues.add(lineValues);
                                }
                                String elemValue = elementValue.getValue();
                                if (tmpParam != null && EParameterFieldType.PASSWORD.equals(tmpParam.getFieldType())) {
                                    elemValue = elementValue.getRawValue();
                                }
                                lineValues.put(elementValue.getElementRef(), elemValue);
                                if (elementValue.getType() != null) {
                                    lineValues.put(elementValue.getElementRef() + IEbcdicConstant.REF_TYPE, elementValue.getType());
                                }
                            }
                        }
                        elemParam.setPropertyValue(pTypeName, tableValues);
                    } else if (param.getFieldType().equals(EParameterFieldType.PASSWORD)) {
                        param.setValue(pType.getRawValue());
                    } else if (param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) {
                        // fix for bug 2193
                        boolean setToCustom = false;
                        if (EmfComponent.REPOSITORY.equals(elemParam.getPropertyValue(EParameterName.PROPERTY_TYPE.getName())) && param.getRepositoryValue() != null && param.getRepositoryValue().equals("ENCODING")) {
                            //$NON-NLS-1$
                            setToCustom = true;
                        }
                        String tempValue = null;
                        IElementParameter iElementParameter = null;
                        Map<String, IElementParameter> childParameters = param.getChildParameters();
                        if (childParameters != null) {
                            iElementParameter = childParameters.get(EParameterName.ENCODING_TYPE.getName());
                            if (iElementParameter != null) {
                                tempValue = (String) iElementParameter.getValue();
                            }
                        }
                        if (tempValue != null && !tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM)) {
                            //$NON-NLS-1$ //$NON-NLS-2$
                            tempValue = tempValue.replaceAll("'", "");
                            //$NON-NLS-1$ //$NON-NLS-2$
                            tempValue = tempValue.replaceAll("\"", "");
                            tempValue = TalendTextUtils.addQuotes(tempValue);
                            if (!tempValue.equals(value)) {
                                setToCustom = true;
                            }
                        }
                        if (iElementParameter != null && setToCustom) {
                            iElementParameter.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
                        }
                        elemParam.setPropertyValue(pTypeName, value);
                    // end of fix for bug 2193
                    } else if (!param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
                        if (param.getRepositoryValue() != null && !param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) {
                            if (repositoryParam != null && EmfComponent.REPOSITORY.equals(repositoryParam.getValue())) {
                                param.setRepositoryValueUsed(true);
                            } else {
                                param.setRepositoryValueUsed(false);
                            }
                        }
                        elemParam.setPropertyValue(pTypeName, value);
                    }
                } else if (//$NON-NLS-1$
                UpdateTheJobsActionsOnTable.isClear && "CLEAR_TABLE".equals(pTypeName) && //$NON-NLS-1$
                "true".equals(pType.getValue()) && "NONE".equals(elemParam.getElementParameter(Process.TABLE_ACTION).getValue())) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    elemParam.setPropertyValue(Process.TABLE_ACTION, "CLEAR");
                    UpdateTheJobsActionsOnTable.isClear = false;
                }
            }
        }
    }
    // update combo list for dbversion
    if (statsDBType != null && statsDBVersion != null) {
        JobSettingVersionUtil.setDbVersion(statsDBVersion, String.valueOf(statsDBType.getValue()), String.valueOf(statsDBVersion.getValue()));
    }
    if (implicitDBType != null && implicitDBVersion != null) {
        JobSettingVersionUtil.setDbVersion(implicitDBVersion, String.valueOf(implicitDBType.getValue()), String.valueOf(implicitDBVersion.getValue()));
    }
}
Also used : Element(org.talend.core.model.process.Element) ArrayList(java.util.ArrayList) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) EList(org.eclipse.emf.common.util.EList) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) IElementParameter(org.talend.core.model.process.IElementParameter) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 24 with Element

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

the class ElementParameter2ParameterType method loadProjectsettingsParameters.

/**
     * DOC zli Comment method "loadProjectsettingsParameters".
     *
     * @param parameters
     */
public static void loadProjectsettingsParameters(ParametersType parameters) {
    IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
    designerCoreService.switchToCurJobSettingsView();
    List<IProcess2> openedProcess = designerCoreService.getOpenedProcess(reference);
    for (IProcess2 process : openedProcess) {
        if (process instanceof Element) {
            Element processElem = (Element) process;
            ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null);
        }
        process.setNeedRegenerateCode(true);
    }
    IProxyRepositoryFactory repositoryFactory = CorePlugin.getDefault().getProxyRepositoryFactory();
    IProcess process = null;
    try {
        List<IRepositoryViewObject> all = repositoryFactory.getAll(ERepositoryObjectType.PROCESS);
        for (IRepositoryViewObject object : all) {
            if (!openedProcess.contains(object)) {
                Item item = object.getProperty().getItem();
                if (item instanceof ProcessItem) {
                    process = designerCoreService.getProcessFromProcessItem((ProcessItem) item);
                    if (process != null && process instanceof IProcess2) {
                        IProcess2 process2 = (IProcess2) process;
                        if (process2 instanceof Element) {
                            Element processElem = (Element) process2;
                            ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null);
                            ProcessType processType = process2.saveXmlFile();
                            if (processType != null) {
                                ((ProcessItem) item).setProcess(processType);
                            }
                            repositoryFactory.save(item);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Element(org.talend.core.model.process.Element) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 25 with Element

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

the class DynamicTabbedPropertySection method setInput.

// private ISelection lastSelection;
/*
     * @Override (non-Java)
     * 
     * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection# setInput(org.eclipse.ui.IWorkbenchPart,
     * org.eclipse.jface.viewers.ISelection)
     */
@Override
public void setInput(final IWorkbenchPart workbenchPart, final ISelection selection) {
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    curRowSize = 0;
    Object input = ((IStructuredSelection) selection).getFirstElement();
    if (input instanceof NodeContainerPart) {
        NodeContainerPart nContainer = (NodeContainerPart) input;
        elem = (Element) nContainer.getParent().getModel();
    } else if (input instanceof NodeTreeEditPart) {
        NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
        elem = (Element) nTreePart.getModel();
    } else if (!(input instanceof NodeReturnsTreeEditPart)) {
        EditPart editPart = (EditPart) input;
        elem = (Element) editPart.getModel();
    }
    if (elem instanceof NodeLabel) {
        elem = ((NodeLabel) elem).getNode();
    }
    if (elem instanceof ConnectionLabel) {
        elem = ((ConnectionLabel) elem).getConnection();
    }
    if (workbenchPart instanceof AbstractMultiPageTalendEditor) {
        part = (AbstractMultiPageTalendEditor) workbenchPart;
    } else {
        if (elem instanceof INode) {
            part = (AbstractMultiPageTalendEditor) ((IProcess2) ((INode) elem).getProcess()).getEditor();
        } else if (elem instanceof IConnection) {
            IConnection conn;
            conn = (IConnection) elem;
            part = (AbstractMultiPageTalendEditor) ((IProcess2) conn.getSource().getProcess()).getEditor();
        } else {
            part = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        }
    }
    super.setInput(part, selection);
    commandStackEventListener = null;
    if ((currentComponent == null) || (!currentComponent.equals(elem.getElementName()))) {
        forceRedraw = true;
        elem.setPropertyValue(updataComponentParamName, Boolean.TRUE);
    }
    currentComponent = elem.getElementName();
}
Also used : INode(org.talend.core.model.process.INode) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Element(org.talend.core.model.process.Element) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) IConnection(org.talend.core.model.process.IConnection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) NodeLabel(org.talend.designer.core.ui.editor.nodes.NodeLabel) IProcess2(org.talend.core.model.process.IProcess2) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

Element (org.talend.core.model.process.Element)37 IProcess (org.talend.core.model.process.IProcess)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 IElementParameter (org.talend.core.model.process.IElementParameter)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 IElement (org.talend.core.model.process.IElement)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 TalendPropertyTabDescriptor (org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor)4 FakeElement (org.talend.designer.core.model.FakeElement)4 Process (org.talend.designer.core.ui.editor.process.Process)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Control (org.eclipse.swt.widgets.Control)3 IEditorPart (org.eclipse.ui.IEditorPart)3 Test (org.junit.Test)3 IProcess2 (org.talend.core.model.process.IProcess2)3 EmptyRepositoryObject (org.talend.core.model.repository.EmptyRepositoryObject)3 Form (org.talend.daikon.properties.presentation.Form)3 ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)3