Search in sources :

Example 1 with ICodeProblemsChecker

use of org.talend.core.language.ICodeProblemsChecker in project tdi-studio-se by Talend.

the class ProblemsAnalyser method checkProblems.

public List<Problem> checkProblems(ExternalMapperData externalData) {
    problems.clear();
    if (externalData != null) {
        checkLookupTablesKeyProblems(externalData);
        ICodeProblemsChecker codeChecker = LanguageProvider.getCurrentLanguage().getCodeChecker();
        if (mapperManager.isCheckSyntaxEnabled()) {
            List<ExternalMapperTable> extInputTables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
            List<ExternalMapperTable> extVarTables = new ArrayList<ExternalMapperTable>(externalData.getVarsTables());
            List<ExternalMapperTable> extOutputTables = new ArrayList<ExternalMapperTable>(externalData.getOutputTables());
            checkExpressionSyntaxProblems(extInputTables, codeChecker);
            checkExpressionSyntaxProblems(extVarTables, codeChecker);
            checkExpressionSyntaxProblems(extOutputTables, codeChecker);
            List<? extends IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getAbstractMapComponent().getIncomingConnections());
            ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
            MapperMain mapperMain = ((MapperComponent) mapperManager.getAbstractMapComponent()).getMapperMain();
            ArrayList<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
            ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
            checkKeysProblems(inputTables);
            checkOutputTablesProblems(extOutputTables);
        }
    }
    return getProblems();
}
Also used : ExternalDataConverter(org.talend.designer.mapper.external.converter.ExternalDataConverter) InputTable(org.talend.designer.mapper.model.table.InputTable) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) ArrayList(java.util.ArrayList) ICodeProblemsChecker(org.talend.core.language.ICodeProblemsChecker) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) MapperMain(org.talend.designer.mapper.MapperMain) MapperComponent(org.talend.designer.mapper.MapperComponent)

Example 2 with ICodeProblemsChecker

use of org.talend.core.language.ICodeProblemsChecker in project tdi-studio-se by Talend.

the class MultipleThreadDynamicComposite method operationInThread.

// refactore to be synchonized with the dispose() method because of TDI-24184
// the synchronized methodis a quick fix but not the ideal one because this method is accessing many attributes
// of the current class that may be modified by other thread (just like "elem" modified by the dispose() method.
protected synchronized void operationInThread() {
    if (elem == null) {
        return;
    }
    // hywang modified for
    List<? extends IElementParameter> listParam = elem.getElementParametersWithChildrens();
    Boolean updateNeeded = (Boolean) elem.getPropertyValue(updataComponentParamName);
    if (updateNeeded != null) {
        if (updateNeeded) {
            if (elem != null) {
                addComponents(forceRedraw);
                elem.setPropertyValue(updataComponentParamName, new Boolean(false));
                forceRedraw = false;
            }
        }
    }
    final ECodeLanguage language = ((RepositoryContext) org.talend.core.CorePlugin.getContext().getProperty(org.talend.core.context.Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
    IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
    final ICodeProblemsChecker syntaxChecker = service.getSyntaxChecker(language);
    List<Problem> javaProblem = null;
    for (int i = 0; i < listParam.size(); i++) {
        if (listParam.get(i).getCategory() == section) {
            if (listParam.get(i).isShow(listParam)) {
                final IElementParameter e = listParam.get(i);
                e.isReadOnly();
                e.isNoCheck();
                if (language == ECodeLanguage.JAVA && javaProblem == null) {
                    if (!e.isReadOnly() && !e.isNoCheck()) {
                        javaProblem = syntaxChecker.checkProblems(null);
                    }
                }
                final List<Problem> nodePros = javaProblem;
                if (generator != null) {
                    AbstractElementPropertySectionController controller = generator.getController(e.getFieldType(), MultipleThreadDynamicComposite.this);
                    if (controller != null) {
                        controller.updateCodeProblems(nodePros);
                        controller.refresh(e, checkErrorsWhenViewRefreshed);
                    }
                }
            }
        }
    }
    if (propertyResized) {
        try {
            removeListener(SWT.Resize, resizeListener);
            getParent().layout();
            composite.pack();
            propertyResized = false;
            addListener(SWT.Resize, resizeListener);
        } catch (Exception e) {
        }
    }
    checkErrorsWhenViewRefreshed = false;
//        long time = TimeMeasure.timeSinceBegin("DC:refresh:" + getCurrentComponent()); //$NON-NLS-1$
//        TimeMeasure.end("DC:refresh:" + getCurrentComponent()); //$NON-NLS-1$
// if (DynamicTabbedPropertySection.DEBUG_TIME) {
//            System.out.println("DC;total;" + getCurrentComponent() + ";" + time); //$NON-NLS-1$ //$NON-NLS-2$
// }
}
Also used : AbstractElementPropertySectionController(org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ICodeProblemsChecker(org.talend.core.language.ICodeProblemsChecker) IElementParameter(org.talend.core.model.process.IElementParameter) Problem(org.talend.core.model.process.Problem) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Aggregations

ICodeProblemsChecker (org.talend.core.language.ICodeProblemsChecker)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ECodeLanguage (org.talend.core.language.ECodeLanguage)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 Problem (org.talend.core.model.process.Problem)1 AbstractElementPropertySectionController (org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController)1 MapperComponent (org.talend.designer.mapper.MapperComponent)1 MapperMain (org.talend.designer.mapper.MapperMain)1 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)1 ExternalDataConverter (org.talend.designer.mapper.external.converter.ExternalDataConverter)1 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)1 InputTable (org.talend.designer.mapper.model.table.InputTable)1 IRunProcessService (org.talend.designer.runprocess.IRunProcessService)1