use of org.talend.core.runtime.process.ITalendProcessJavaProject 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;
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject 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);
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class TalendDefaultJavaEditor method doSetInput.
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
if (input instanceof FileEditorInput) {
try {
// IRepositoryService repositoryService = DesignerPlugin.getDefault().getRepositoryService();
// IProxyRepositoryFactory repFactory = repositoryService.getProxyRepositoryFactory();
IRunProcessService runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
// I think runProcessService can't be null, and should throw exception if it is null
ITalendProcessJavaProject talendJavaProject = runProcessService.getTalendProcessJavaProject();
if (talendJavaProject == null) {
return;
}
//$NON-NLS-1$
final String pathSeperator = "/";
String routinesFolderName = ERepositoryObjectType.ROUTINES.getFolder().split(pathSeperator)[1];
String talendSrcFolderPath = talendJavaProject.getSrcFolder().getLocation().toString() + pathSeperator;
String routineFolderPath = talendSrcFolderPath + routinesFolderName + pathSeperator;
IFile openedFile = ((FileEditorInput) input).getFile();
String openedFilePath = openedFile.getLocation().toString();
boolean isRoutine = openedFilePath.startsWith(routineFolderPath);
boolean isTalendGeneratedFile = openedFilePath.startsWith(talendSrcFolderPath);
//$NON-NLS-1$
String systemRoutineFolderName = "system";
String systemRoutineFolderPath = routineFolderPath + systemRoutineFolderName + pathSeperator;
boolean isSystemRoutine = openedFilePath.startsWith(systemRoutineFolderPath);
if (isSystemRoutine) {
fileType = FILE_TYPE_TALEND_GENERATED_READONLY;
} else if (isRoutine) {
fileType = FILE_TYPE_TALEND_GENERATED_READONLY;
} else if (isTalendGeneratedFile) {
fileType = FILE_TYPE_TALEND_GENERATED_READONLY;
} else {
fileType = FILE_TYPE_OTHERS;
}
} catch (Throwable e) {
CommonExceptionHandler.process(e, Priority.WARN);
fileType = FILE_TYPE_OTHERS;
}
}
super.doSetInput(input);
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class GenerateGrammarController method addReferenceJavaFile.
/**
* Store file to file system. Actually, it locates src/routines/xx DOC ytao Comment method "addReferenceJavaFile".
*
* @param routineItem
* @param copyToTemp
* @return
* @throws SystemException
*/
private IFile addReferenceJavaFile(RoutineItem routineItem, boolean copyToTemp) throws SystemException {
FileOutputStream fos = null;
try {
IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return null;
}
String label = routineItem.getProperty().getLabel();
IFile file = talendProcessJavaProject.getSrcFolder().getFile(JavaUtils.JAVA_ROUTINES_DIRECTORY + '/' + label + JavaUtils.JAVA_EXTENSION);
if (copyToTemp) {
String routineContent = new String(routineItem.getContent().getInnerContent());
if (!label.equals(ITalendSynchronizer.TEMPLATE)) {
routineContent = routineContent.replaceAll(ITalendSynchronizer.TEMPLATE, label);
File f = file.getLocation().toFile();
fos = new FileOutputStream(f);
fos.write(routineContent.getBytes());
fos.close();
}
}
if (!file.exists()) {
file.refreshLocal(1, null);
}
return file;
} catch (Exception e) {
throw new SystemException(e);
} finally {
try {
fos.close();
} catch (Exception e) {
// ignore me even if i'm null
ExceptionHandler.process(e);
}
}
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class JavaProcessor method getBasePathClasspath.
protected String getBasePathClasspath() throws ProcessorException {
final String classPathSeparator = extractClassPathSeparator();
final String rootWorkingDir = getRootWorkingDir(false);
StringBuffer basePath = new StringBuffer(50);
if (isExportConfig() || isRunAsExport()) {
// current path.
basePath.append('.');
if (rootWorkingDir.length() > 0) {
basePath.append(classPathSeparator);
// $ROOT_PATH
basePath.append(rootWorkingDir);
}
if (isExternalUse()) {
// for tRunJob with independent option and init pom for classpath
List<String> codesJars = PomUtil.getCodesExportJars(this.getProcess());
for (String codesJar : codesJars) {
basePath.append(classPathSeparator);
if (rootWorkingDir.length() > 0) {
basePath.append(rootWorkingDir);
basePath.append(JavaUtils.PATH_SEPARATOR);
}
basePath.append(getBaseLibPath());
basePath.append(JavaUtils.PATH_SEPARATOR);
basePath.append(codesJar);
}
} else {
String outputPath = getCodeLocation();
if (outputPath != null) {
outputPath = outputPath.replace(ProcessorUtilities.TEMP_JAVA_CLASSPATH_SEPARATOR, classPathSeparator);
if (outputPath.endsWith(classPathSeparator)) {
// remove the seperator
outputPath = outputPath.substring(0, outputPath.length() - 1);
}
if (!Platform.OS_WIN32.equals(getTargetPlatform())) {
String libraryPath = ProcessorUtilities.getLibraryPath();
if (libraryPath != null) {
String unixRootPath = getRootWorkingDir(true);
outputPath = outputPath.replace(libraryPath, unixRootPath + libraryPath);
}
}
}
basePath.append(classPathSeparator);
basePath.append(outputPath);
}
// FIXME for old build (JobJavaScriptsManager) temp, when "ProcessorUtilities.setExportConfig(dir,true)"
String codeLocation = getCodeLocation();
if (codeLocation != null && codeLocation.contains(JavaUtils.SYSTEM_ROUTINE_JAR) && codeLocation.contains(JavaUtils.USER_ROUTINE_JAR) && !basePath.toString().contains(JavaUtils.SYSTEM_ROUTINE_JAR)) {
basePath.append(classPathSeparator);
codeLocation = codeLocation.replace(ProcessorUtilities.TEMP_JAVA_CLASSPATH_SEPARATOR, classPathSeparator);
basePath.append(codeLocation);
}
} else {
ITalendProcessJavaProject tProcessJvaProject = this.getTalendJavaProject();
IFolder classesFolder = tProcessJvaProject.getOutputFolder();
String outputPath = classesFolder.getLocation().toPortableString();
// add current path
outputPath += classPathSeparator + '.';
basePath.append(outputPath);
}
return basePath.toString();
}
Aggregations