Search in sources :

Example 11 with ECodeLanguage

use of org.talend.core.language.ECodeLanguage 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)

Example 12 with ECodeLanguage

use of org.talend.core.language.ECodeLanguage in project tmdm-studio-se by Talend.

the class DeployOnMDMAction method init.

/*
     * (non-Javadoc)
     *
     * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = true;
    ECodeLanguage language = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
    if (selection.isEmpty() || language == ECodeLanguage.PERL) {
        // only Java project can see the action
        setEnabled(false);
        return;
    }
    if (MDMServerHelper.getServers().size() == 0) {
        setEnabled(false);
        return;
    }
    List<RepositoryNode> nodes = selection.toList();
    for (RepositoryNode node : nodes) {
        if (node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.PROCESS) {
            continue;
        }
        canWork = false;
        break;
    }
    setEnabled(canWork);
}
Also used : RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 13 with ECodeLanguage

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

the class ChangeReturnTypeOfServerAliveResult method convertItem.

private boolean convertItem(Item item, ProcessType processType) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    ECodeLanguage language = getProject().getLanguage();
    EList node = processType.getNode();
    EList connections = processType.getConnection();
    for (Object n : node) {
        NodeType type = (NodeType) n;
        EList elementParameterList = type.getElementParameter();
        for (Object elem : elementParameterList) {
            ElementParameterType elemType = (ElementParameterType) elem;
            if (language.equals(ECodeLanguage.JAVA)) {
                if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
                    //$NON-NLS-1$
                    Matcher match = PATTERN_GET.matcher(elemType.getValue());
                    String replace = getReplaceValue(match);
                    if (replace != null && replace.length() > 0) {
                        elemType.setValue(replace);
                        modified = true;
                    }
                }
            }
            // for table
            EList elemValue = elemType.getElementValue();
            for (Object elemV : elemValue) {
                ElementValueType elemVal = (ElementValueType) elemV;
                if (language.equals(ECodeLanguage.JAVA)) {
                    if (elemVal.getValue() != null && elemVal.getValue().contains("tServerAlive")) {
                        //$NON-NLS-1$
                        Matcher match = PATTERN_GET.matcher(elemVal.getValue());
                        String replace = getReplaceValue(match);
                        if (replace != null && replace.length() > 0) {
                            elemVal.setValue(replace);
                            modified = true;
                        }
                    }
                }
            }
        }
    }
    // the links
    for (Object n : connections) {
        ConnectionType type = (ConnectionType) n;
        EList elementParameterList = type.getElementParameter();
        for (Object elem : elementParameterList) {
            ElementParameterType elemType = (ElementParameterType) elem;
            if (language.equals(ECodeLanguage.JAVA)) {
                if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
                    //$NON-NLS-1$
                    Matcher match = PATTERN_GET.matcher(elemType.getValue());
                    String replace = getReplaceValue(match);
                    if (replace != null && replace.length() > 0) {
                        elemType.setValue(replace);
                        modified = true;
                    }
                }
            }
        }
    }
    if (modified) {
        factory.save(item, true);
    }
    return modified;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EList(org.eclipse.emf.common.util.EList) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) Matcher(java.util.regex.Matcher) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 14 with ECodeLanguage

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

the class AbstractRoutineAction method openRoutineEditor.

/**
     * DOC smallet Comment method "openRoutineEditor".
     * 
     * @param routineItem
     * @throws SystemException
     * @throws PartInitException
     */
protected IEditorPart openRoutineEditor(RoutineItem routineItem, boolean readOnly) throws SystemException, PartInitException {
    if (routineItem == null) {
        return null;
    }
    ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
    ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
    ITalendSynchronizer routineSynchronizer;
    switch(lang) {
        case JAVA:
            routineSynchronizer = service.createJavaRoutineSynchronizer();
            break;
        case PERL:
            routineSynchronizer = service.createPerlRoutineSynchronizer();
            break;
        default:
            //$NON-NLS-1$
            throw new UnsupportedOperationException(Messages.getString("AbstractRoutineAction.unknowLanguage") + lang);
    }
    // check if the related editor is open.
    IWorkbenchPage page = getActivePage();
    IEditorReference[] editorParts = page.getEditorReferences();
    //$NON-NLS-1$ //$NON-NLS-2$
    String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
    boolean found = false;
    IEditorPart talendEditor = null;
    for (IEditorReference reference : editorParts) {
        IEditorPart editor = reference.getEditor(false);
        if (talendEditorID.equals(editor.getSite().getId())) {
            // TextEditor talendEditor = (TextEditor) editor;
            RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
            if (editorInput.getItem().equals(routineItem)) {
                page.bringToTop(editor);
                found = true;
                talendEditor = editor;
                break;
            }
        }
    }
    if (!found) {
        IFile file = null;
        ProjectManager projectManager = ProjectManager.getInstance();
        boolean flag = projectManager.isInCurrentMainProject(routineItem);
        if (!flag) {
            // is ref project
            file = routineSynchronizer.getRoutinesFile(routineItem);
        } else {
            // need open from item file with multiple version
            boolean needForceRefresh = false;
            if (!ProxyRepositoryFactory.getInstance().isLocalConnectionProvider()) {
                // in case only routine.item file modified, better refresh every time, especially for git mode
                needForceRefresh = true;
            }
            routineSynchronizer.syncRoutine(routineItem, true, needForceRefresh);
            ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            String lastVersion = factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
            String curVersion = routineItem.getProperty().getVersion();
            if (curVersion != null && curVersion.equals(lastVersion)) {
                file = routineSynchronizer.getFile(routineItem);
            } else {
                file = routineSynchronizer.getRoutinesFile(routineItem);
            }
        }
        if (file == null) {
            return null;
        }
        RepositoryEditorInput input = new RoutineEditorInput(file, routineItem);
        input.setReadOnly(readOnly);
        talendEditor = page.openEditor(input, talendEditorID);
    }
    return talendEditor;
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IFile(org.eclipse.core.resources.IFile) IEditorPart(org.eclipse.ui.IEditorPart) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) ProjectManager(org.talend.repository.ProjectManager) IEditorReference(org.eclipse.ui.IEditorReference) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 15 with ECodeLanguage

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

the class AbstractSqlpatternAction method openSQLPatternEditor.

/**
     * DOC smallet Comment method "openRoutineEditor".
     * 
     * @param item
     * @throws SystemException
     * @throws PartInitException
     */
public IEditorPart openSQLPatternEditor(SQLPatternItem item, boolean readOnly) throws SystemException, PartInitException {
    if (item == null) {
        return null;
    }
    ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
    ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
    ISQLPatternSynchronizer routineSynchronizer = service.getSQLPatternSynchronizer();
    // check if the related editor is open.
    IWorkbenchPage page = getActivePage();
    IEditorReference[] editorParts = page.getEditorReferences();
    //$NON-NLS-1$ //$NON-NLS-2$
    String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
    boolean found = false;
    IEditorPart talendEditor = null;
    for (IEditorReference reference : editorParts) {
        IEditorPart editor = reference.getEditor(false);
        if (talendEditorID.equals(editor.getSite().getId())) {
            // TextEditor talendEditor = (TextEditor) editor;
            RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
            Item item2 = editorInput.getItem();
            if (item2 != null && item2 instanceof SQLPatternItem && item2.getProperty().getId().equals(item.getProperty().getId())) {
                if (item2.getProperty().getVersion().equals(item.getProperty().getVersion())) {
                    page.bringToTop(editor);
                    found = true;
                    talendEditor = editor;
                    break;
                } else {
                    page.closeEditor(editor, false);
                }
            }
        }
    }
    if (!found) {
        routineSynchronizer.syncSQLPattern(item, true);
        IFile file = routineSynchronizer.getSQLPatternFile(item);
        if (file == null) {
            return null;
        }
        RepositoryEditorInput input = new RepositoryEditorInput(file, item);
        input.setReadOnly(readOnly);
        //$NON-NLS-1$            
        talendEditor = page.openEditor(input, talendEditorID);
    }
    return talendEditor;
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IFile(org.eclipse.core.resources.IFile) ISQLPatternSynchronizer(org.talend.designer.codegen.ISQLPatternSynchronizer) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IEditorPart(org.eclipse.ui.IEditorPart) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) Item(org.talend.core.model.properties.Item) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Aggregations

ECodeLanguage (org.talend.core.language.ECodeLanguage)29 RepositoryContext (org.talend.core.context.RepositoryContext)5 HashMap (java.util.HashMap)4 StyledText (org.eclipse.swt.custom.StyledText)4 IEditorPart (org.eclipse.ui.IEditorPart)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IElementParameter (org.talend.core.model.process.IElementParameter)4 RepositoryEditorInput (org.talend.core.repository.ui.editor.RepositoryEditorInput)4 IFile (org.eclipse.core.resources.IFile)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 IEditorReference (org.eclipse.ui.IEditorReference)3 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 ICodeGeneratorService (org.talend.designer.codegen.ICodeGeneratorService)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 EList (org.eclipse.emf.common.util.EList)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 UnnotifiableColorStyledText (org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText)2 Item (org.talend.core.model.properties.Item)2