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.
59 lines
1.5 KiB
59 lines
1.5 KiB
package com.fr.nx.app.designer; |
|
|
|
import com.fr.base.extension.FileExtension; |
|
import com.fr.design.mainframe.AbstractAppProvider; |
|
import com.fr.design.mainframe.JTemplate; |
|
import com.fr.design.mainframe.JWorkBook; |
|
import com.fr.exception.TplLockedException; |
|
import com.fr.file.FILE; |
|
import com.fr.log.FineLoggerFactory; |
|
import com.fr.main.impl.WorkBook; |
|
import com.fr.nx.cptx.utils.CptxFileUtils; |
|
|
|
/** |
|
* 支持设计器打开cptx文件 |
|
*/ |
|
public class CptxApp extends AbstractAppProvider<WorkBook> { |
|
|
|
public CptxApp() { |
|
StartupAssist.initDesignModule(); |
|
} |
|
|
|
@Override |
|
public String[] defaultExtensions() { |
|
return new String[]{FileExtension.CPTX.getExtension()}; |
|
} |
|
|
|
@Override |
|
public void process() { |
|
super.process(); |
|
StartupAssist.reloadTemplate(); |
|
} |
|
|
|
/** |
|
* 该方法只是为了读到cptx中的cpt |
|
* |
|
* @param tplFile file |
|
* @return template |
|
*/ |
|
@Override |
|
public JTemplate<WorkBook, ?> openTemplate(FILE tplFile) { |
|
return new JWorkBook(asIOFile(tplFile), tplFile); |
|
} |
|
|
|
@Override |
|
public WorkBook asIOFile(FILE file) { |
|
WorkBook workBook = null; |
|
try { |
|
workBook = CptxFileUtils.getWorkBook(file.asInputStream()); |
|
} catch (TplLockedException e) { |
|
throw new RuntimeException(e); |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
} |
|
if (workBook == null) { |
|
workBook = new WorkBook(); |
|
} |
|
return workBook; |
|
} |
|
}
|
|
|