Search in sources :

Example 41 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class TalendJavaSourceViewer method isRouteProcess.

/**
     * if the current process is a route process or not
     * 
     * @return
     */
private static boolean isRouteProcess() {
    try {
        IRunProcessService runProcessService = getRunProcessService();
        if (runProcessService == null) {
            return false;
        }
        IProcess activeProcess = runProcessService.getActiveProcess();
        boolean isRouteProcess = (activeProcess != null && "org.talend.camel.designer.ui.editor.RouteProcess".equals(activeProcess.getClass().getName()));
        return isRouteProcess;
    } catch (Throwable e) {
        return false;
    }
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) IProcess(org.talend.core.model.process.IProcess)

Example 42 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class TalendJavaSourceViewer method updateContents.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.viewer.ReconcilerViewer#setContents(org.eclipse.jface.text.IDocument)
     */
@Override
public void updateContents() {
    if (getDocument() == null) {
        return;
    }
    InputStream codeStream = new ByteArrayInputStream(getDocument().get().getBytes());
    try {
        IRunProcessService runProcessService = getRunProcessService();
        if (file == null && runProcessService != null) {
            ITalendProcessJavaProject talendProcessJavaProject = runProcessService.getTalendProcessJavaProject();
            if (talendProcessJavaProject == null) {
                return;
            }
            file = talendProcessJavaProject.getSrcFolder().getFile(JavaUtils.JAVA_INTERNAL_DIRECTORY + '/' + filename);
            file.setContents(codeStream, true, false, null);
            initializeModel();
        } else {
            // only happen sometimes with a "fast click" (file don't exist yet).
            if (getViewerRegion().getLength() == 0) {
                return;
            } else {
                file.setContents(codeStream, true, false, null);
            }
        }
    } catch (CoreException e) {
    // don't display any error.
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject)

Example 43 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class JavaSQLPatternSynchronizer method getSQLPatternFile.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.codegen.ISQLPatternSynchronizer#getSQLPattern(org.talend.core.model.properties.SQLPatternItem
     * )
     */
@Override
public IFile getSQLPatternFile(SQLPatternItem item) throws SystemException {
    IRunProcessService service = CodeGeneratorActivator.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return null;
    }
    String basePath = JavaUtils.JAVA_SQLPATTERNS_DIRECTORY + '/' + item.getEltName();
    // init user defined folder
    talendProcessJavaProject.getResourceSubFolder(null, basePath + '/' + JavaUtils.JAVA_USER_DEFINED);
    IFolder systemFolder = talendProcessJavaProject.getResourceSubFolder(null, basePath + '/' + JavaUtils.JAVA_SYSTEM_DIRECTORY);
    IFile file = systemFolder.getFile(item.getProperty().getLabel() + JavaUtils.JAVA_SQLPATTERN_EXTENSION);
    return file;
}
Also used : IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IFolder(org.eclipse.core.resources.IFolder)

Example 44 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class JavaRoutineSynchronizer method getTestContainerFile.

private IFile getTestContainerFile(ProcessItem item, String projectFolderName, String folderName, String jobName) {
    IRunProcessService service = CodeGeneratorActivator.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return null;
    }
    IFolder srcFolder = talendProcessJavaProject.getTestSrcFolder();
    String packageName = JavaResourcesHelper.getJobClassPackageFolder(item, true);
    IFile file = srcFolder.getFile(packageName + '/' + jobName + "Test" + JavaUtils.JAVA_EXTENSION);
    return file;
}
Also used : IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IFolder(org.eclipse.core.resources.IFolder)

Example 45 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class JavaRoutineSynchronizer method syncModule.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.codegen.IRoutineSynchronizer#syncRoutine(org.talend .core.model.properties.RoutineItem)
     */
private static void syncModule(File[] modules) throws SystemException {
    IRunProcessService service = CodeGeneratorActivator.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return;
    }
    final IFolder systemFolder = talendProcessJavaProject.getSrcSubFolder(null, JavaUtils.JAVA_ROUTINES_DIRECTORY + '/' + JavaUtils.JAVA_SYSTEM_DIRECTORY);
    syncModules(modules, systemFolder);
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IRunProcessService (org.talend.designer.runprocess.IRunProcessService)51 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)30 IFolder (org.eclipse.core.resources.IFolder)17 IFile (org.eclipse.core.resources.IFile)15 File (java.io.File)14 IOException (java.io.IOException)13 ArrayList (java.util.ArrayList)12 CoreException (org.eclipse.core.runtime.CoreException)11 URL (java.net.URL)9 PersistenceException (org.talend.commons.exception.PersistenceException)9 MalformedURLException (java.net.MalformedURLException)7 IPath (org.eclipse.core.runtime.IPath)7 IProcess (org.talend.core.model.process.IProcess)7 ProcessorException (org.talend.designer.runprocess.ProcessorException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 DocumentException (org.dom4j.DocumentException)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 HashSet (java.util.HashSet)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3