1 package com.proalpha.pds.ui;
3 import java.nio.file.Paths;
4 import java.util.ArrayList;
7 import org.eclipse.core.resources.IFile;
8 import org.eclipse.core.runtime.IPath;
14 static final String USEREXITFILEEXTENTIONS =
"cdf,fld,if,i,lib,p,pds,tdf,w,cls";
15 static final String USEREXITCUSTOMLEVELS =
"c,q,u,x,y,z";
16 List<String> userexitfiletypes =
new ArrayList<>();
30 String[] results = USEREXITFILEEXTENTIONS.split(
",");
32 for (String result : results) {
33 if (result.equalsIgnoreCase(filename.getFileExtension() )) {
50 if(file.getFileExtension().equalsIgnoreCase(
"cls")) {
51 return claasUserExitExists(file,customlevel);
55 newFilePath = file.getRawLocation();
56 newFilePath = newFilePath.removeFileExtension();
57 newFilePath = newFilePath.addFileExtension(getUserExitFileExt(file,customlevel));
58 return newFilePath.toFile().exists();
62 private static String getUserExitFileExt(IFile pAprocedure,String customLevel) {
64 return customLevel.toLowerCase() +
"x" + pAprocedure.getFileExtension().substring(0, 1);
68 private static boolean claasUserExitExists(IFile file, String customlevel) {
72 IPath newFilePath = file.getRawLocation();
73 String newFileName = newFilePath.removeFileExtension().toString();
76 if(newFileName.toUpperCase().endsWith(customlevel.toUpperCase())) {
77 newFileName = newFileName.substring(0,newFileName.length() - 1);
78 if (Paths.get(newFileName +
".cls").toFile().exists()){
83 if (newFileName.endsWith(
"Std"))
85 newFileName = newFileName.substring(0, newFileName.length() - 3);
87 return Paths.get(newFileName + customlevel.toUpperCase() +
".cls").toFile().exists();