帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

package com.fr.start.common;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager;
import com.fr.file.FILE;
import com.fr.file.FILEFactory;
import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils;
import org.jetbrains.annotations.Nullable;
import java.io.File;
/**
* created by Harrison on 2022/07/09
**/
public class DesignerStartupUtil {
@Nullable
public static FILE convertArgs2FILE(String[] args) {
// p:需要打开这个报表文件,这个代码不能删除.
FILE file = null;
for (String arg : args) {
if (ComparatorUtils.equals("demo", arg)) {
file = FILEFactory.createFILE(FILEFactory.ENV_PREFIX + DesignerEnvManager.getEnvManager().getLastOpenFile());
break;
}
File f = new File(arg);
String path = f.getAbsolutePath();
if (isAcceptFilePathEnd(path)) {
file = new FileFILE(f);
}
}
return file;
}
private static boolean isAcceptFilePathEnd(String path) {
FileExtension[] acceptFileExtensions = new FileExtension[]{
FileExtension.CPT, FileExtension.XLS, FileExtension.XLSX, FileExtension.FRM, FileExtension.CHT, FileExtension.VIS
};
for (FileExtension acceptFileExtension : acceptFileExtensions) {
String[] extensions = acceptFileExtension.getExtensions();
for (String extension : extensions) {
if (path.endsWith("." + extension)) {
return true;
}
}
}
return false;
}
}