|
|
@ -1,7 +1,8 @@ |
|
|
|
package com.fr.design.utils; |
|
|
|
package com.fr.design.utils; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
|
|
import com.fr.base.io.BaseBook; |
|
|
|
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
@ -15,6 +16,7 @@ import com.fr.stable.CoreConstants; |
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.server.lock.TplOperator; |
|
|
|
import com.fr.workspace.server.lock.TplOperator; |
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import javax.swing.SwingWorker; |
|
|
|
import javax.swing.SwingWorker; |
|
|
|
|
|
|
|
|
|
|
@ -58,7 +60,19 @@ public class TemplateUtils { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
byte[] content = WorkContext.getWorkResource().readFully(oldPath); |
|
|
|
byte[] content = new byte[0]; |
|
|
|
|
|
|
|
if (!needOpen) { |
|
|
|
|
|
|
|
// 从当前编辑模板中生成备份文件
|
|
|
|
|
|
|
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
|
|
|
BaseBook target = template.getTarget(); |
|
|
|
|
|
|
|
if (target != null) { |
|
|
|
|
|
|
|
target.export(outputStream); |
|
|
|
|
|
|
|
content = outputStream.toByteArray(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
content = WorkContext.getWorkResource().readFully(oldPath); |
|
|
|
|
|
|
|
} |
|
|
|
if (ArrayUtils.isEmpty(content)) { |
|
|
|
if (ArrayUtils.isEmpty(content)) { |
|
|
|
throw new Exception(oldPath + " content is empty" ); |
|
|
|
throw new Exception(oldPath + " content is empty" ); |
|
|
|
} |
|
|
|
} |
|
|
@ -90,7 +104,7 @@ public class TemplateUtils { |
|
|
|
DesignerContext.getDesignerFrame().openTemplate(file); |
|
|
|
DesignerContext.getDesignerFrame().openTemplate(file); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
SaveFailureHandler.Handler.FullDisk.process(e); |
|
|
|
SaveFailureHandler.getInstance().process(e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|